Skip to content
Advertisement

Tag: async-await

async function javascript is not running in background?

This output I want is this 1 2 3! in then but the async function behaves synchronously and does not let the 3! print until after the long loops are done executing. I thought if the async keyword is used, it runs the function inside in the background? I basically want the 2 long loops to run in the background.

Throwing errors in async await functions and catching from where it’s called

How can we catch error from an async await function from where it’s called? For example, I have a React component which calls a async-await function imported from another module. When I use Promise.reject(“An unknown has occurred”); in that function, so in my React component why can’t I get the error in asyncAwaitFunction.catch((e)=>console.log(e))? I even tried throw “An unknown occured”,

Get AWS S3 Upload URL – NodeJs AWS-SDK

I’m pretty sure I’m missing something very obvious here, but: I’m uploading a file to an s3 bucket using aws-sdk as follows: I’m able to log the upload url successfully, however the awsURL returned is an array, not the data.Location value – shouldn’t the data.Location be returned from the callback? Answer Convert s3.upload to return a promise:

Please help, I have a problem, My conditional didnt work with data I gained from mongoDB.find()

I have a problem, I code using javascript and I use mongodb or mongoose as the database. I have a little information about async / await I made a variable called “thread” to get data from mongoDB using const thread = await Threads.findOne({threadId}) the thread will have data: { “_id”: “6044d0d8940c3b2494ce135d”, “threadId”:”A001} After that I want to use the _id

Advertisement