DEV Community

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

Posted on

3 1

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!

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay