CEC-1691 Handle 503 errors (#156)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
errorHandler,
|
||||
getAuthHeaderOptions,
|
||||
fetchRespHandler,
|
||||
addQueryParams,
|
||||
@@ -15,7 +16,9 @@ const vehiclesAPI = {
|
||||
getAuthHeaderOptions(token)
|
||||
),
|
||||
body: JSON.stringify(vehicle),
|
||||
}).then(fetchRespHandler),
|
||||
})
|
||||
.then(fetchRespHandler)
|
||||
.catch(errorHandler),
|
||||
|
||||
deleteVehicle: async (vin, token) =>
|
||||
fetch(`${API_ENDPOINT}/vehicle/${vin}`, {
|
||||
@@ -24,7 +27,9 @@ const vehiclesAPI = {
|
||||
{ "Content-Type": "application/json" },
|
||||
getAuthHeaderOptions(token)
|
||||
),
|
||||
}).then(fetchRespHandler),
|
||||
})
|
||||
.then(fetchRespHandler)
|
||||
.catch(errorHandler),
|
||||
|
||||
getConnections: async (vins, token) => {
|
||||
const u = `${API_ENDPOINT}/carsconnected?vins=${vins.join(",")}`;
|
||||
@@ -34,7 +39,9 @@ const vehiclesAPI = {
|
||||
{ "Content-Type": "application/json" },
|
||||
getAuthHeaderOptions(token)
|
||||
),
|
||||
}).then(fetchRespHandler);
|
||||
})
|
||||
.then(fetchRespHandler)
|
||||
.catch(errorHandler);
|
||||
},
|
||||
|
||||
getECUs: async (search, token) => {
|
||||
@@ -45,7 +52,9 @@ const vehiclesAPI = {
|
||||
{ "Content-Type": "application/json" },
|
||||
getAuthHeaderOptions(token)
|
||||
),
|
||||
}).then(fetchRespHandler);
|
||||
})
|
||||
.then(fetchRespHandler)
|
||||
.catch(errorHandler);
|
||||
},
|
||||
|
||||
getModels: async (token) =>
|
||||
@@ -55,7 +64,9 @@ const vehiclesAPI = {
|
||||
{ "Content-Type": "application/json" },
|
||||
getAuthHeaderOptions(token)
|
||||
),
|
||||
}).then(fetchRespHandler),
|
||||
})
|
||||
.then(fetchRespHandler)
|
||||
.catch(errorHandler),
|
||||
|
||||
getLocations: async (token) =>
|
||||
fetch(`${API_ENDPOINT}/carslocations`, {
|
||||
@@ -64,7 +75,9 @@ const vehiclesAPI = {
|
||||
{ "Content-Type": "application/json" },
|
||||
getAuthHeaderOptions(token)
|
||||
),
|
||||
}).then(fetchRespHandler),
|
||||
})
|
||||
.then(fetchRespHandler)
|
||||
.catch(errorHandler),
|
||||
|
||||
getState: async (token, vin) =>
|
||||
fetch(`${API_ENDPOINT}/carstate?vin=${vin}`, {
|
||||
@@ -73,7 +86,9 @@ const vehiclesAPI = {
|
||||
{ "Content-Type": "application/json" },
|
||||
getAuthHeaderOptions(token)
|
||||
),
|
||||
}).then(fetchRespHandler),
|
||||
})
|
||||
.then(fetchRespHandler)
|
||||
.catch(errorHandler),
|
||||
|
||||
getVehicle: async (vin, token) =>
|
||||
fetch(`${API_ENDPOINT}/vehicle/${vin}`, {
|
||||
@@ -82,7 +97,9 @@ const vehiclesAPI = {
|
||||
{ "Content-Type": "application/json" },
|
||||
getAuthHeaderOptions(token)
|
||||
),
|
||||
}).then(fetchRespHandler),
|
||||
})
|
||||
.then(fetchRespHandler)
|
||||
.catch(errorHandler),
|
||||
|
||||
getVehicles: async (search, token) => {
|
||||
const u = addQueryParams(`${API_ENDPOINT}/vehicles`, search);
|
||||
@@ -92,7 +109,9 @@ const vehiclesAPI = {
|
||||
{ "Content-Type": "application/json" },
|
||||
getAuthHeaderOptions(token)
|
||||
),
|
||||
}).then(fetchRespHandler);
|
||||
})
|
||||
.then(fetchRespHandler)
|
||||
.catch(errorHandler);
|
||||
},
|
||||
|
||||
getYears: async (token) =>
|
||||
@@ -102,7 +121,9 @@ const vehiclesAPI = {
|
||||
{ "Content-Type": "application/json" },
|
||||
getAuthHeaderOptions(token)
|
||||
),
|
||||
}).then(fetchRespHandler),
|
||||
})
|
||||
.then(fetchRespHandler)
|
||||
.catch(errorHandler),
|
||||
|
||||
sendCommand: async (vins, command, parameters, token) =>
|
||||
fetch(`${API_ENDPOINT}/vehiclecommand`, {
|
||||
@@ -116,7 +137,9 @@ const vehiclesAPI = {
|
||||
command,
|
||||
parameters,
|
||||
}),
|
||||
}).then(fetchRespHandler),
|
||||
})
|
||||
.then(fetchRespHandler)
|
||||
.catch(errorHandler),
|
||||
|
||||
updateVehicle: async (vin, vehicle, token) =>
|
||||
fetch(`${API_ENDPOINT}/vehicle/${vin}`, {
|
||||
@@ -125,8 +148,10 @@ const vehiclesAPI = {
|
||||
{ "Content-Type": "application/json" },
|
||||
getAuthHeaderOptions(token)
|
||||
),
|
||||
body: JSON.stringify(vehicle)
|
||||
}).then(fetchRespHandler),
|
||||
body: JSON.stringify(vehicle),
|
||||
})
|
||||
.then(fetchRespHandler)
|
||||
.catch(errorHandler),
|
||||
};
|
||||
|
||||
export default vehiclesAPI;
|
||||
|
||||
Reference in New Issue
Block a user