I'm trying to manage errors properly in my code but I'm getting a warning like what I'm not handling the rejected promise, see below :
UnhandledPromiseRejectionWarning: Error: Request failed with status code 401
at createError (/Users/a/Documents/export/node_modules/axios/lib/core/createError.js:16:15)
at settle (/Users/a/Documents/export/node_modules/axios/lib/core/settle.js:18:12)
at IncomingMessage.handleStreamEnd (/Users/a/Documents/export/node_modules/axios/lib/adapters/http.js:201:11)
at IncomingMessage.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1092:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
Here is my code :
const axios = require('axios');
axios.get('API_REQUEST', {
'auth': {
'bearer': 'NOT_WORKING_TOKEN' // To force the API to return an error ;)
}
}).catch((error)=>{
throw error;
})
For now I just want my program to crash without the warning when the error is throwing.