DEV Community

Cover image for The Dead Simple Way to Get Weather Information for Your Next JS Project
Phillip Shim
Phillip Shim

Posted on

The Dead Simple Way to Get Weather Information for Your Next JS Project

 

With the recent announcement of Apple acquiring DarkSky API. DarkSky API has currently closed down any new enrollments. The other compatible alternative I found one was the OpenWeatherMap.

The Challenge

Using APIs raw from their official documentation is cumbersome and cognitively taxing. You need to be mindful of all the different query parameters, filters and many options to build out URLs for different methods. You also need to deal with inconsistent conventions and refer back to the docs frequently get them straight.

For example, take a look at a few ways to get current weather from OpenWeatherMap. 😰

Alt Text

The Solution

How about we abstract from building out the URLs by yourself and let a library to the heavy-lifting for you? Now Introducing

openweathermap-ts 🎉

 

The library is built with

  • Typescript - Get all the type checking and IntelliSense goodness out of the box.
  • Promises - No callbacks FTW! 💪

Now it's as beautiful as

Alt Text

It's declarative, intuitive, and flexible!
Typing in arguments hurt your wrists? Don't worry, just set up the config object once and you are good.

Alt Text

The efficiency is crazy with easy-to-use methods you can easily get up and going. Don't deal with anything other than business logic. Build smart and use the library. 😎

Repo

https://github.com/shimphillip/openweathermap-ts

 

Thank y'all for taking some time to read the article!

Top comments (0)