The simplicity of setting a timeout in Axios is one of the reasons some developers prefer it to fetch(). async/await syntax fits great with fetch() because it simplifies the work with promises. If the request fails due to some network problems, the promise is rejected. When the request completes, the promise is resolved with the Response object. Why is fetch a Promise?įetch() starts a request and returns a promise. A fetch() promise does not reject on HTTP errors ( 404, etc.). A fetch() promise only rejects when a network error is encountered (which is usually when there’s a permissions issue or similar). The promise resolves to the Response object representing the response to your request.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |