carpediemusC
BuildShip2y ago
8 replies
carpediemus

weatherapi problem

Trying to fetch weather data from weatherapi, the ai wrote me a code:


import fetch from 'node-fetch';
export default async function fetchWeatherForecast({
cityName,
apiKey
}) {
const url = https://api.weatherapi.com/v1/forecast.json?key={apiKey}&q={cityName}&days=3;
const response = await fetch(url);
const data = await response.json();
return data;
}


But i keep getting an error whenever i try to test the call.
Running the url with the api key in the browser returns the results without an issue.

{"error":{"message":"An error occurred while fetching: TypeError [ERR_INVALID_URL]: Invalid URL"},"label":"build node","message":"An error occurred while fetching: TypeError [ERR_INVALID_URL]: Invalid URL"}

I am just starting out with buildship so any help would be appreciated.
Was this page helpful?