Handle api error json (#18)

* Handle api error json

* Fix get vehicles error handling
Update .env.template
This commit is contained in:
John Wu
2021-03-17 15:11:41 -07:00
committed by GitHub
parent 2e1f4a7a7c
commit bf401e68eb
10 changed files with 69 additions and 47 deletions

View File

@@ -1,3 +1,5 @@
import { fetchRespHandler } from "../utils/http";
const AUTH_URL = process.env.REACT_APP_AUTH_SERVICE_URL || "https://gw-dev.fiskerdps.com/compute_auth";
const CALLBACK_URL = process.env.REACT_APP_AUTH_CALLBACK_URL || "https://dev-ota-admin.fiskerdps.com";
@@ -13,7 +15,7 @@ const auth = {
code,
redirect: CALLBACK_URL,
})
}).then((response) => response.json()),
}).then(fetchRespHandler),
verify: (idToken) => fetch(`${AUTH_URL}/verify`, {
method: "POST",
@@ -21,7 +23,7 @@ const auth = {
"Content-Type": "application/json"
},
body: JSON.stringify({ token: idToken })
}).then((response) => response.json()),
}).then(fetchRespHandler),
refresh: (refreshToken) => fetch(`${AUTH_URL}/refresh`, {
method: "POST",
@@ -29,7 +31,7 @@ const auth = {
"Content-Type": "application/json"
},
body: JSON.stringify({ refresh_token: refreshToken })
}).then((response) => response.json()),
}).then(fetchRespHandler),
};
export default auth;