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}`);}
try
JS
For TypeScript
Thank you!