0

I've tried to include everything I could find in the request, yet the error remains. How do I find out what's causing this? My AdBlocker extension has been deactivated.

await fetch('http://127.0.0.1:8080/hxo.json?dummy=2s21', 
{headers: {'Content-Type': 'application/json; charset=UTF-8'}, 
cache: "no-store", 
pragma: 'no-cache'})
.then(resp => resp.json())
.then(data => console.log(data))
.catch(err => console.error('problem w fetch: ', err))

screenshot of error in browser

VLAZ
  • 26,331
  • 9
  • 49
  • 67
Daniel
  • 23
  • 2
  • 7
  • 1
    Hi, might be some another extension other than ad block? Like Privacy Badger or something – Honza Feb 17 '22 at 12:07
  • seems like an Authentication issue... did you use postman for view the json? is it working? – fixedDrill Feb 17 '22 at 12:12
  • Getting this one now before the previous errors: ``` Access to fetch at 'http://127.0.0.1:8080/hxxo.json?dummy=2s21' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. ``` – Daniel Feb 17 '22 at 12:15
  • if it is an authencation issue,, you need to pass the params with header. see here for [Basic authorization](https://stackoverflow.com/questions/34815853/react-native-fetch-and-basic-authentication/71122256#71122256). – fixedDrill Feb 17 '22 at 12:16
  • Changing the URL to 127.0.0.1:8080 instead worked. Is there a workaround to this? (no authentication required, just fetching a json file) – Daniel Feb 17 '22 at 12:16
  • clear the cache , try this [https://technowikis.com/5231/err-blocked-by-client-chrome-solution](https://technowikis.com/5231/err-blocked-by-client-chrome-solution). – fixedDrill Feb 17 '22 at 12:33

1 Answers1

-1

add method and remove Pragma property might solve the issue

fetch('url', 
  method: 'GET',
{headers: {'Content-Type': "application/json"}
})