const cityUrl =
'https://weather-api-ninjas.p.rapidapi.com/v1/weather?city=delhi';
const requestOptions = {
method: 'GET',
headers: {
'X-RapidAPI-Key': 'ce580959b4msh04ac7f304c1ee24p143e88jsncf6cf022f1d6',
'X-RapidAPI-Host': 'weather-api-ninjas.p.rapidapi.com',
},
};
(async () => {
try {
const apiResponse = await fetch(cityUrl, requestOptions);
const data = await apiResponse.json();
console.log(data);
} catch (error) {
console.error(error);
}
})();
I attempted to retrieve weather information from RapidAPI but ran into an issue. I simply copied the provided code snippet for the fetch operation.