In a ReactNative component, when I press a button I got the "Possible Unhandled Promise Rejection" error when I execute this function:
async onAdd(item) {
try {
const response = await fetch('url', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
event_id: item.id,
event_type: item.event_type,
})
});
const responseJson = await response.json();
} catch (error) {
error(error);
}
}
I do not know why since its in a try / catch block.
UPDATED
This is the error function:
function error(value) {
if (console) {
console.error(value)
}
}