I’m new to both GCF and Javascript async and have been struggling with this. I perform a fetch call initially and then pass that response as a parameter to a second function which then also performs a separate fetch call. During the second function, my empty initialized json gets properties added to it, and when that function completes, I want
Tag: async-await
javascript async fetch function
I am trying to create a recursive function that sends a PUT request for every integer of a given array, and call another function at the end of it. But it seems that it calls the load_mailbox() function before fetching the last item of the array. I know that this should be better implemented using async / await. Can someone
How to cancel token using a custom Axios instance?
I have an custom Axios instance using axios.create(). I would like to use the cancellation feature of Axios but the request fired from custom instance never gets cancelled. It does’t get detected in the .isCancel() method. But it works fine when used with the global Axios object. I don’t understand why cancellation doesn’t work with a custom Axios instance. Answer
How to handle streaming data using fetch?
I have used async for with great success in handling output streams from processes with node.js, but I’m struggling to get something that I was hoping could “just work” with the browser fetch API. This works great to async’ly handle chunks of output streaming from a process: (in an async function context here of course) I tried to do something
Awaiting an async function when using Mongodb in node.js
I am trying to retrieve all documents from a MongoDB cluster. I’ve been searching online and using the async/await keywords and have wrote the following code From my understanding of the async/await pattern theconsole.log(questions) line should only be hit after the return inside GetQuestions is hit, however that is not the case. Answer You should return a Promise with the
Upgrading the night-watch from 1.3.2 to 1.3.4 breaks the existing test specially in page object
I was using night-watch version 1.3.2. All the tests were working fine till I update the night-watch to its latest version 1.3.4. The test breaks specially in the page object. I’ve checked the release notes for night-watch 1.3.4 and it has the new feature to support page object with async/await – https://github.com/nightwatchjs/nightwatch/releases. I believe the error message i am getting
Why doesn’t TypeScript enforce async/await on promise?
I have the following code. performAsyncAction performs an async action and returns Promise<Response>. In someFunction , I was surprised that TypeScript doesn’t warn about not using await on a function that returns a promise. I found a relevant linting rule that may help promise-function-async Answer It is not an error, it is intended behaviour. The Promises existed long before async/await,
‘await’ has no effect on the type of this expression
I searched about this but I didn’t find anything specific for what I need. If there is one, please, share here. I’m trying to create a generic service to be called in various components. Since it’s a function that requests data from an external source, I need to treat it as an asynchronous function. Problem is, the editor returns the
Jquery async/await ajax call
I’m currently using 3 ajax call methods (3 of them are executing back-to-back). I must have a time delay in between the second ajax call and the third one. If I add “async:false” in the second ajax, everything works like a charm. However, I found out that this is really a terrible practice and shouldn’t be using. So I decided
TypeError: fs.createReadStream is not a function
I prefer to use promises rather than callbacks so I’ve used util.promisify. I’ve received TypeError: fs.createReadStream is not a function at const attachments = {attachment: fs.createReadStream(‘kitty.png’)}; line. How can I solve that? Answer fs.promises is not a superset of fs. While it replaces some methods on fs with methods of the same core name that return a promise, it does