Hi there!
I have been struggling with “TypeError: Cannot read property ‘json’ of undefined”. I’d like to flatten (the nested function) below
mongodbDocument.save((err, data) => {
if (err) return console.error(err);
res.json({
original_url: data.original_url,
short_url: data.short_url
});
});
with
const saveAndRespond = (doc) => {
doc.save((err, data, res) => {
if (err) return console.error(err);
res.json({
original_url: data.original_url,
short_url: data.short_url
});
});
};
Here is a link: https://glitch.com/edit/#!/mountainous-fearless-shrimp
I would mean a lot to me if you could help me!
/Mattias