In my frontend (React Native) i'm trying to catch this message with try/catch:
try {
const headers = {
headers: {
Authorization: `Bearer ${token}`,
},
};
const {data} = yield call(api.post, '/respostaquiz', awnserQuiz, headers);
} catch (error) {
console.tron.log(error);
}
But when i look in the console.tron.log(error)
i don't find the message that i defined in my custom exception:
{ "message": "Request failed with status code 400", "name": "Error", "stack": "createError@http://10.0.3.2:8081/index.bundle?platform=android&dev=true&minify=false:207509:26\nsettle@http://10.0.3.2:8081/index.bundle?platform=android&dev=true&minify=false:207499:25\nhandleLoad@http://10.0.3.2:8081/index.bundle?platform=android&dev=true&minify=false:207403:15\ndispatchEvent@http://10.0.3.2:8081/index.bundle?platform=android&dev=true&minify=false:32304:31\nsetReadyState@http://10.0.3.2:8081/index.bundle?platform=android&dev=true&minify=false:31373:27\n__didCompleteResponse@http://10.0.3.2:8081/index.bundle?platform=android&dev=true&minify=false:31215:29\nemit@http://10.0.3.2:8081/index.bundle?platform=android&dev=true&minify=false:3318:42\n__callFunction@http://10.0.3.2:8081/index.bundle?platform=android&dev=true&minify=false:2650:49\nhttp://10.0.3.2:8081/index.bundle?platform=android&dev=true&minify=false:2363:31\n__guard@http://10.0.3.2:8081/index.bundle?platform=android&dev=true&minify=false:2604:15\ncallFunctionReturnFlushedQueue@http://10.0.3.2:8081/index.bundle?platform=android&dev=true&minify=false:2362:21\ncallFunctionReturnFlushedQueue@[native code]", "config": { "url": "https://xxx.herokuapp.com/respostaquiz", "method": "post", "data": "{\"id_quiz\":807,\"start_date_time\":\"2020-01-29T09:54:23.000Z\",\"end_date_time\":\"2020-01-29T09:54:34.000Z\",\"percentage_correct\":33.33333333333333,\"questions\":[{\"id\":1602,\"resposta\":\"sDFASDF\"},{\"id\":1603,\"resposta\":\"CAT\"},{\"id\":1604,\"resposta\":\"1\"}]}", "headers": { "Accept": "application/json, text/plain, /", "Content-Type": "application/json;charset=utf-8", "Authorization": "Bearer xxx" }, "baseURL": "https://xxx.herokuapp.com", "transformRequest": [ " transformRequest() " ], "transformResponse": [ " transformResponse() " ], "timeout": 0, "adapter": " xhrAdapter() ", "xsrfCookieName": "XSRF-TOKEN", "xsrfHeaderName": "X-XSRF-TOKEN", "maxContentLength": -1, "validateStatus": " validateStatus() " } }
How i can get this error message?