import axios from “axios”;
export const baseUrl = “https://bayut.p.rapidapi.com”;
export const fetchApi = async (url) => {
const { data } = await axios.request(url, {
method: “GET”,
headers: {
“RapidAPI-Key”:process.env.API_KEY,
“RapidAPI-Host”: “bayut.p.rapidapi.com”,
},
});
return data;
};
i am getting undefined after trying to fetch data with that??
Join in the discussion - add comment below:
Hello,
What was the data const sent to the endpoint? You need to send enough information so I can reproduce your issue. In addition, you may manually test it again by using an HTTP client such as postman.com to validate the case.
Regards.