Sign up with OpenWeather API, get a (hopefully) free API key and add it to the environment.ts files
Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.
Run ng build to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.
๐ป Code Examples
// Function that takes a city name as input and returns an Observable using a Weather interfacegetWeatherForCity(city: string): Observable<Weather>{const params =newHttpParams({fromObject: {q: city}});returnthis.httpGet<Weather>('weather',params).pipe(map((data: Weather)=>({
...data,image: `https://openweathermap.org/img/wn/${data.weather[0].icon}@2x.png`,})),delay(500));}privatehttpGet<T>(url: string,params: HttpParams): Observable<T>{
params =params.append('appid',environment.apiKey);params=params.append('lang','en');params=params.append('units','metric');returnthis.http.get<T>(`${this.baseUrl}/data/2.5/weather`,{ params });}
๐ Features
dark mode toggle
stylish weather card
๐ Status & To-Do List
Status: Working
To-Do: Correct 5 type errors "Property 'main' does not exist on type 'unknown'."