Skip to main content
Question

Javascript async functions not running

  • April 4, 2023
  • 0 replies
  • 88 views

christianto88

I have this simple javascript code 

var requestOptions = {
method: 'POST',
headers: {
"Content-Type":"text/plain"
},
body: inputData['html']
};
const url = 'my-url'
fetch(url, requestOptions)
callback(ull,{})

I dont want to wait for the fetch request to finish and return immediately. It seems like if i dont use “await”, the fetch function wont be invoked, but if i use await, the fetch function will be invoked. Is this expected behavior?

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.