useCustom transform response.
I have an array of vehicle models fetched from api. The sample model as follows
My data model looks like this:
How to map vehicle_type and fuel_types to vehicleType and fuelType of data model.
[
{
"id": 95,
"name": "Nexon",
"transmission": [
"automatic",
"manual"
],
"fuel_types": [
"petrol",
"diesel",
"electric",
"hybrid"
],
"vehicle_type": "suv"
}
][
{
"id": 95,
"name": "Nexon",
"transmission": [
"automatic",
"manual"
],
"fuel_types": [
"petrol",
"diesel",
"electric",
"hybrid"
],
"vehicle_type": "suv"
}
]My data model looks like this:
interface IVehicleModel {
id: number;
name: string;
transmission: string[];
fuelTypes: string[];
vehicleType: string;
make?: string;
}interface IVehicleModel {
id: number;
name: string;
transmission: string[];
fuelTypes: string[];
vehicleType: string;
make?: string;
}How to map vehicle_type and fuel_types to vehicleType and fuelType of data model.
const { data, isLoading } = useCustom<VehicleResponse>({
url: `${API_URL}/api/v1/vehicles`,
method: "get",
config: {
query: {
offset: currentPage - 1,
limit: limit,
},
},
});const { data, isLoading } = useCustom<VehicleResponse>({
url: `${API_URL}/api/v1/vehicles`,
method: "get",
config: {
query: {
offset: currentPage - 1,
limit: limit,
},
},
});