1
I am trying to call the API but is returning the warning error:
"Possible Unhandled Promise Rejection".
There are similar questions, but none specific to React Hooks from what I’ve seen.
Follow the codes
api.js
import axios from 'axios';
const api = axios.create({
baseURL: 'http://localhost:3001/api'
});
export default api;
Reportscreen.js
useEffect(() => {
async function loadReports() {
const response = await api.get('/reports');
console.log(response.data);
}
loadReports();
}, []);
Remark: on the backend
already set the Cors
and other necessary dependencies .
you’re sure the mistake is there?
– novic
As amazing as it sounds yes... It’s the only piece of Javascript, the rest of the code is graphical element
– Matheus Costa