fetch-api

Removing Fetch API default timeout

半腔热情 提交于 2020-02-25 04:28:28
问题 I'm sending queries to my server using native fetch from Google Chrome or Mozilla Firefox: fetch(url, { method: 'POST', body: formData, credentials: 'include' }) I set up a server to send a response after 3 minutes and realized that both browsers only wait 2 minutes. Firefox resend the request once more before failing. Is there a way to define a timeout bigger than 2 minutes (say infinite)? 回答1: As far as I read fetch()'s documentation on MDN, it does not have any way to specify a timeout.

Removing Fetch API default timeout

邮差的信 提交于 2020-02-25 04:28:02
问题 I'm sending queries to my server using native fetch from Google Chrome or Mozilla Firefox: fetch(url, { method: 'POST', body: formData, credentials: 'include' }) I set up a server to send a response after 3 minutes and realized that both browsers only wait 2 minutes. Firefox resend the request once more before failing. Is there a way to define a timeout bigger than 2 minutes (say infinite)? 回答1: As far as I read fetch()'s documentation on MDN, it does not have any way to specify a timeout.

Chrome - Fetch API cannot load file. How to workaround?

こ雲淡風輕ζ 提交于 2020-02-23 09:05:25
问题 I have the following two files: index.html <html> <head> <meta charset="utf-8" /> <title>Web Page</title> <style type="text/css"> .text { display: inline-block; font-family: tahoma; font-size: 14px; max-width: 400px; background-color: #ddedff; padding: 10px; text-align: justify; } </style> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script type="text/javascript"> $(function(){ get_data('info.txt'); }); function get_data

How can we check if response for the request came from Service Worker

对着背影说爱祢 提交于 2020-02-23 04:47:33
问题 In Google Chrome console next to the status code of HTTP Request we have info (from ServiceWorker) . Can Request be aware somehow that the Response came from ServiceWorker? Comparing date from Response Headers maybe? 回答1: By design, a response returned via a FetchEvent#respondWith() is meant to be indistinguishable from a response that had no service worker involvement. This applies regardless of whether the response we're talking about is obtained via XMLHttpRequest , window.fetch() , or

Header keys become lowercase when interacting with API - React native

廉价感情. 提交于 2020-02-22 07:33:06
问题 When interacting with API, the custom Header key always become lowercase. I'm use Fetch , Axios , XMLHttpRequest and Frisbee (javascript network library) but the key always lowercase My snippet code like this (with fetch() method), The key I'm push is: 'Token-Api' but the server receive: 'token-api' , so it's show the error 401. It's work with Postman: const request = 'https://abcxyz'; fetch(request, { method: 'GET', headers: { 'Content-Type': 'application/json', 'Token-Api':'...abcxyz....' }

Header keys become lowercase when interacting with API - React native

耗尽温柔 提交于 2020-02-22 07:32:01
问题 When interacting with API, the custom Header key always become lowercase. I'm use Fetch , Axios , XMLHttpRequest and Frisbee (javascript network library) but the key always lowercase My snippet code like this (with fetch() method), The key I'm push is: 'Token-Api' but the server receive: 'token-api' , so it's show the error 401. It's work with Postman: const request = 'https://abcxyz'; fetch(request, { method: 'GET', headers: { 'Content-Type': 'application/json', 'Token-Api':'...abcxyz....' }

Fetch API, Chrome, and 404 Errors [duplicate]

元气小坏坏 提交于 2020-01-31 13:03:49
问题 This question already has answers here : Suppress Chrome 'Failed to load resource' messages in console (3 answers) Closed yesterday . I'm playing around with fetch , and I noticed that only Chrome displays an error when a resource I am fetching doesn't exist (aka a 404): Both Edge and Firefox don't do that, and 404 errors using fetch don't seem to trigger a NetworkError to have my catch error handler to get notified. What should I do to avoid this error in Chrome? In case you need this, my

Fetch API, Chrome, and 404 Errors [duplicate]

夙愿已清 提交于 2020-01-31 12:56:56
问题 This question already has answers here : Suppress Chrome 'Failed to load resource' messages in console (3 answers) Closed yesterday . I'm playing around with fetch , and I noticed that only Chrome displays an error when a resource I am fetching doesn't exist (aka a 404): Both Edge and Firefox don't do that, and 404 errors using fetch don't seem to trigger a NetworkError to have my catch error handler to get notified. What should I do to avoid this error in Chrome? In case you need this, my

Requesting API with fetch in javascript has CORS policy error

若如初见. 提交于 2020-01-30 11:23:48
问题 I'm trying to call some APIs with fetch in my javascript code. I'm developing with ReactJs in my machine and have another development in the same network developing the API with .net in another machine. With postman, I can call the API, but with fetch no. I try to call another API in other server and the result was successful. I'm using fetch and tried to use axios too. I have found in other question in stack overflow this API: https://gturnquist-quoters.cfapps.io/api/random. The answer says

react-native fetch - request body - Unexpected EOF

二次信任 提交于 2020-01-30 11:18:07
问题 in my react-native application, I'm trying to make fetch request with body . But, I get error message of unexpected EOF . Actually, the request is made, I mean I can see through backend logs that request is sent, whereas, right after the request, it shows error message. Here is my fetch method. var Url = "https://----------"; return fetch(Url, { method: "POST", headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify({'number': '11111111-'}) }) .then