this doesn't help me, I have api that returns 400 as bad request, with a body, I can't read the body from response since the request is directly thrown to catch where there's no body!
Any suggestions please?
try{// with destructuring constres=awaitaxios.get('https://example.com/someApi');// without destructuring constres=awaitaxios.get('https://example.com/someApi');returnres.data;}catch(err){console.log(`Error: ${err?.response?.data}`);}
For TypeScript
try{// with destructuring constres=awaitaxios.get<{feild:type}>('https://example.com/someApi');// without destructuring constres=awaitaxios.get<{feild:type}>('https://example.com/someApi');returnres.data;}catch(err){console.log(`Error: ${(errasAxiosError)?.response?.data}`);}
this doesn't help me, I have api that returns 400 as bad request, with a body, I can't read the body from response since the request is directly thrown to catch where there's no body!
Any suggestions please?
*Actually I found the solution: *
try
JS
For TypeScript
Thank you!