Getting “TypeError: failed to fetch” when the request hasn't actually failed

前端 未结 5 1744
予麋鹿
予麋鹿 2020-12-01 09:05

I\'m using fetch API within my React app. The application was deployed on a server and was working perfectly. I tested it multiple times. But, suddenly the application stopp

5条回答
  •  执笔经年
    2020-12-01 09:40

    I have a similar problem and as I'm newbie, here are some facts for somebody to comment:

    I'm sending form data to Google sheet this way (scriptURL is https://script.google.com/macros/s/AKfy..., showSuccess() is showing a simple image):

    fetch(scriptURL, {method: 'POST', body: new FormData(form)})
    .then(response => showSuccess())
    .catch(error => alert('Error! ' + error.message))
    

    Executed in Edge my HTML doesn't show error and Network tab reports this 3 requests: Executed in Chrome my HTML (index.htm) shows Failed to fetch error and Network tab reports this 2 requests: The value in the second column is blocked:other and there is also an error in Console tab:

    GET https://script.googleusercontent.com/macros/echo?user_content_key=D-ABF... net::ERR_BLOCKED_BY_CLIENT

    In order to suspend installed Chrome extensions, I executed my code in an Incognito window and there is no error message and Network tab reports this 2 requests:

    My guess is that something (extension?) prevents Chrome to read the request's answer (the GET request is blocked).

提交回复
热议问题