I have tried a few things that seem reasonable to me, but they don't work. I could move the fetch into the function I actually need it in, but I will need it again elsewhere and that's not very DRY.
Every time I put myself out there and ask a question I am embarrassed to ask, I always find the answer 5 minutes later, and this time is no different. The answer is async / await! Of course it is.
Hi Isa, this is very helpful! I have a really dumb question...feel free to ignore me, I'm new to node and promises and kinda new to Javascript.
In the node-fetch example, what if what I wanted to do with the json was return it?
Like:
const getStuffFromWhatever = (item) => {
let url = whatever?thing=item
}
console.log(getStuffFromWhatever('puppy dogs')
I have tried a few things that seem reasonable to me, but they don't work. I could move the fetch into the function I actually need it in, but I will need it again elsewhere and that's not very DRY.
Every time I put myself out there and ask a question I am embarrassed to ask, I always find the answer 5 minutes later, and this time is no different. The answer is async / await! Of course it is.
Thanks for letting me talk it out.
Always happy to be your rubber ducky! :)