Relative Content

Tag Archive for javascriptpromise

How to upload base64 using an axios request

For all of the convert to base 64 functions I have found on stack overflow it requires using a promise. So i create a function that generates a new promise and I await on it for the response then return that. I use this function for all the files I am converting to base64 however for some reason when I get to my backend with the request it still says its a object.promise so I am assuming the await is not working correctly.

Why must I add a “then” after “finally” in order to chain promises?

Per this fiddle, if I try to call a second promise function from the .finally() block of the first promise, the second promise resolves but the resolve value is “undefined”.
However, if I call the second promise function in a .then block after the .finally block, everything works as expected. Why can’t I call the second promise in the .finally block of the first promise?

Will a promise chain without a final call to then() that implicitly returns undefined or a call to catch() leave a promise pending indefinitely?

I’ve noticed in a promise chain that if I don’t make a final call to catch() or then() that returns a promise resolved with undefined (implicit or otherwise), it will leave a promise unresolved. This seems like a memory leak risk, so I’d like to ask if it’s always necessary to use one of the aforementioned ways of finishing up a promise chain? Of course, it seems sensible to allows catch anything that goes wrong in the promise chain anyway.