I'm trying to fetch data from a API running locally on port 5000 my device. From working on React web apps I'm used to setting the proxy in package.json like this:
"proxy": "https://localhost:5000"
Now I try to fetch something from the API like this:
fetch("/colours", { method: "GET", headers: {"Content-Type": "application/json;charset=utf-8", } })...
Sadly if I now run my application on my browser it still says that it sends the request to http://localhost:19006/colours
. The responds contains HTML for a reload button.
I also checked on my APIs console, no request ever arrives there. I have tried the usual tricks of deleting package-lock.json
and node_modules
and installing again.
Is my approach to API requests fundamentally wrong for React Native?