0

I knew that in try block {data} is response data, but cannot understand what is data: in code. Here I am making a travel advisor which gives you your location's restaurants. For that I am using rapidapi.

import axios from 'axios';

export const getPlacesData = async (type, sw, ne) => {
//Here in try, axios call api and get response
  try {
  //I am asking about below const{data:....}
    const { data: { data } } = await axios.get(`https://travel-advisor.p.rapidapi.com/${type}/list-in-boundary`, {

      params: {

        bl_latitude: sw.lat,

        bl_longitude: sw.lng,

        tr_longitude: ne.lng,

        tr_latitude: ne.lat,

      },

      headers: {

        'x-rapidapi-key': process.env.REACT_APP_RAPID_API_TRAVEL_API_KEY,

        'x-rapidapi-host': 'travel-advisor.p.rapidapi.com',

      },

    });
   //It returns desired data
    return data;

  } catch (error) {
   //It console log error if  any error
    console.log(error);

  }

};


What's data:? What's the purpose to use that data:?

0 Answers0