Retrieve data from MongoDb Compass

Viewed 25

I'm trying to pull a data from "CarDetails" database. To add, I am trying to pull a data from inside "CarDetails" namely "years_used". So far I manage to pull the entire "CarDetails" data instead of just one specific data.

const getCarDetails = async () => {
var device_info = await deviceInfoPlugin.getDeviceInfo();
setLoading(true);
const res = await MarketingApi.GetAdminCarDetails(
  route.params.car_id,
  device_info.deviceUUID
);
console.log('CarDetails',res);
if (res.status === 200) {
 setLoading(false);
 setCarDetails(res.data.data); //fetch all the data
 console.log(res.data.data); //display data
} else {
  setLoading(false);
  ResponseError(res);
}

Trying to fetch "years_used"

const getCarDetailsYearsUsed = async () => {
var device_info = await deviceInfoPlugin.getDeviceInfo();
setLoading(true);
const res = await MarketingApi.GetAdminCarDetails(
  route.params.voucher_id,
  device_info.deviceUUID
);
console.log('YearsUsed',res);
if (res.status === 200) {
  setLoading(false);
  setCarDetails.years_used(res.data.data); //fetch the data?
  console.log(res.data.data); //display data
} else {
  setLoading(false);
  ResponseError(res);
}};

Any help is appreciated

0 Answers
Related