CEC-4772 - carsconnected takes VINs in req body (#397)
This commit is contained in:
@@ -113,7 +113,7 @@ export const FleetProvider = ({ children }) => {
|
||||
throw new Error(`Get fleet vehicles error. ${result.message}`);
|
||||
}
|
||||
|
||||
const connectionsResult = await vehiclesAPI.getConnections(result.data, token)
|
||||
const connectionsResult = await vehiclesAPI.getConnections({ "VINs": result.data }, token)
|
||||
if (result.error) {
|
||||
setFleetVehicles([])
|
||||
throw new Error(`Get vehicles connections error. ${result.message}`);
|
||||
|
||||
@@ -35,7 +35,7 @@ export const VehicleProvider = ({ children }) => {
|
||||
try {
|
||||
if (cars.length === 0) return;
|
||||
const vins = cars.map((car) => car.vin);
|
||||
const result = await api.getConnections(vins, token);
|
||||
const result = await api.getConnections({ "VINs": vins }, token);
|
||||
|
||||
if (result.error) {
|
||||
throw new Error(`Add connections error. ${result.message}`);
|
||||
@@ -80,7 +80,7 @@ export const VehicleProvider = ({ children }) => {
|
||||
const getConnections = async (vins, token) => {
|
||||
try {
|
||||
setBusy(true);
|
||||
const result = await api.getConnections(vins, token);
|
||||
const result = await api.getConnections({ "VINs": vins }, token);
|
||||
if (result.error)
|
||||
throw new Error(`Get connections error. ${result.message}`);
|
||||
return result;
|
||||
|
||||
@@ -116,7 +116,7 @@ const vehiclesAPI = {
|
||||
getConnections: async (vins) => {
|
||||
const result = {};
|
||||
|
||||
vins.forEach((vin) => {
|
||||
vins.VINs.forEach((vin) => {
|
||||
result[vin] = true;
|
||||
result["2:" + vin] = false;
|
||||
});
|
||||
|
||||
@@ -41,13 +41,14 @@ const vehiclesAPI = {
|
||||
.catch(errorHandler),
|
||||
|
||||
getConnections: async (vins, token) => {
|
||||
const u = `${API_ENDPOINT}/carsconnected?vins=${vins.join(",")}`;
|
||||
const u = `${API_ENDPOINT}/carsconnected`;
|
||||
return fetch(u, {
|
||||
method: "GET",
|
||||
method: "POST",
|
||||
headers: Object.assign(
|
||||
{ "Content-Type": "application/json" },
|
||||
getAuthHeaderOptions(token)
|
||||
),
|
||||
body: JSON.stringify(vins),
|
||||
})
|
||||
.then(fetchRespHandler)
|
||||
.catch(errorHandler);
|
||||
|
||||
Reference in New Issue
Block a user