DEV Community

Cover image for Weather-emoji
Lucas.T
Lucas.T

Posted on

Weather-emoji

Get the weather with an emoji ☀️ 🌈


Install:

Run

npm install -D weather-emoji
Enter fullscreen mode Exit fullscreen mode

Import the package:

const weatherEmoji = require('weather-emoji');
Enter fullscreen mode Exit fullscreen mode

Note - We're using the openweather API to fetch the data, it requires that you create a key, click on the link to register and generate your key.

Usage:

const WeatherEmoji = require("weather-emoji");
const weatherEmoji = new WeatherEmoji(secretApiKey);

const emojiParis = weatherEmoji.getWeather("paris", true).then(data => data);

console.log(emojiParis.emoji); // return emoji
Enter fullscreen mode Exit fullscreen mode

With async / await:

const WeatherEmoji = require("weather-emoji");

(async () => {
    const weatherEmoji = new WeatherEmoji(secretApiKey);

    const emojiNewYork = await weatherEmoji.getWeather("new york", true);
    console.log(emojiNewYork.emoji);
})()
Enter fullscreen mode Exit fullscreen mode

More informations here - https://www.npmjs.com/package/weather-emoji

Happy coding ✨🧑‍💻

Discussion (0)