I'm new in React.Js, and have some problem when getting data from Node.js API. It gives the following error :
Error: Network Error
createError createError.js:16
handleError xhr.js:83
dispatchXhrRequest xhr.js:80
xhrAdapter xhr.js:12
dispatchRequest dispatchRequest.js:52
promise callback*request Axios.js:61
method Axios.js:76
wrap bind.js:9
getMemberList service.jsx:8
Ember 2
React 6
unstable_runWithPriority scheduler.development.js:653
React 10
js index.js:8
Webpack 7
service.jsx:14
I tried the API with Postman and its working fine. Accessing the API from mobile app is working too. Backend is using Express and already put cors inside it. I put this inside index.js in backend
var cors = require('cors')
app.use(cors());
This is my code from react :
export async function getMemberList() {
await Axios.get("http://localhost:6000/api/v1/spesialisasi/", {headers}).then(
(res) => {
console.log(res);
}
).catch(
(error) => {
console.log(error);
}
)
}
This is the log from network tab in inspect element
Any advice for this? Thank you.