Trying to retrieve data from an API running locally on port 5000 of my device, I recalled setting the proxy in package.json when working on React web applications:
"proxy": "https://localhost:5000"
Attempting to fetch information from the API using this method:
fetch("/colours", {
method: "GET",
headers: {
"Content-Type": "application/json;charset=utf-8"
}
})...
Unfortunately, upon running the application in my browser, it still indicates sending the request to http://localhost:19006/colours
and the response contains HTML for a reload button.
Reviewing my API's console showed that no requests were reaching it. I attempted common troubleshooting methods like deleting package-lock.json
and node_modules
, then reinstalling them. However, the issue persists.
Could my approach to API requests be fundamentally incorrect for React Native?