Skip to content

Commit

Permalink
fix: add axioserror type on error
Browse files Browse the repository at this point in the history
  • Loading branch information
Stun3R committed Oct 19, 2021
1 parent 50262f3 commit 1140bbb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/lib/strapi.ts
@@ -1,5 +1,6 @@
// Module dependencies & types
import axios, {
AxiosError,
AxiosInstance,
AxiosRequestConfig,
AxiosResponse,
Expand Down Expand Up @@ -95,15 +96,17 @@ export class Strapi {
});
return response.data;
} catch (error) {
const e = error as AxiosError;

// Strapi error or not
if (!error.response) {
if (!e.response) {
throw {
status: 500,
message: error.message,
message: e.message,
original: error,
};
} else {
const { status, data }: AxiosResponse = error.response;
const { status, data }: AxiosResponse = e.response;

// format error message
let message;
Expand Down

0 comments on commit 1140bbb

Please sign in to comment.