How to set withCredentials=true
to fetch
which return promise. Is the following correct :
fetch(url,{ method:'post', headers, withCredentials: true });
I think the MDN documentation talked about everything about http-requesting except this point: withCredentials
No, fetch is not part of them. They only define the language (syntax and semantics) and a few builtin objects.
POST request using fetch API:To do a POST request we need to specify additional parameters with the request such as method, headers, etc. In this example, we'll do a POST request on the same JSONPlaceholder and add a post in the posts. It'll then return the same post content with an ID.
The Fetch API provides a JavaScript interface for accessing and manipulating parts of the HTTP pipeline, such as requests and responses. It also provides a global fetch() method that provides an easy, logical way to fetch resources asynchronously across the network.
Got it here :
credentials: 'include'
and not
withCredentials: true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With