admin管理员组

文章数量:1406453

I'm trying to ask an API with the fetch mand:

    fetch('');

and chrome keep answer me :

net::ERR_FAILED

TypeError: Failed to fetch

I don't understand what's wrong with this simple code. Can anyone help me ?

Thanks

I'm trying to ask an API with the fetch mand:

    fetch('http://fr1.api.radio-browser.info/json/tags');

and chrome keep answer me :

net::ERR_FAILED

TypeError: Failed to fetch

I don't understand what's wrong with this simple code. Can anyone help me ?

Thanks

Share edited Mar 20, 2022 at 8:14 VLAZ 29.2k9 gold badges63 silver badges84 bronze badges asked Mar 20, 2022 at 8:13 Khan From ChedumKhan From Chedum 311 gold badge1 silver badge6 bronze badges 1
  • 1 Check the network tab to see what the reason is. – VLAZ Commented Mar 20, 2022 at 8:14
Add a ment  | 

1 Answer 1

Reset to default 3

If you catch the error after calling fetch, you should see a more descriptive error:

// HTTP
fetch('http://fr1.api.radio-browser.info/json/tags')
    .catch(console.error);

Mixed Content: The page at 'https://fr1.api.radio-browser.info/json/tags' was loaded over HTTPS, but requested an insecure resource 'http://fr1.api.radio-browser.info/json/tags'. This request has been blocked; the content must be served over HTTPS.

Try fetching using https:

// HTTPS
fetch('https://fr1.api.radio-browser.info/json/tags')
    .then(res => res.json())
    .then(console.log)
    .catch(console.error);

本文标签: Why does fetch in javascript return netERRFAILED in every caseStack Overflow