npm install
In your src folder, create a lib folder and inside that, make an API.js file. Inside that file, paste in
const API_KEY = 'YOUR SECRET API KEY YOU GET WHEN YOU SIGN UP FOR A KEY';
function getCoordinatesFromCityName(location) {
return fetch(`https://api.openweathermap.org/data/2.5/find?q=${location}&type=like&units=imperial&appid=${API_KEY}`)
.then(response => response.json());
}
function getForecast(lat=39.7392, lng=-104.9848) {
return fetch(`https://api.openweathermap.org/data/2.5/forecast?lat=${lat}&lon=${lng}&units=imperial&appid=${API_KEY}`)
.then(response => response.json());
}
export default {
getCoordinatesFromCityName,
getForecast
};
npm run serve
npm run build