How to use others API in my website?

 To Use others API to get data, first thing you need is API_KEY.

Some API's are :

    To get random quotes :  https://api.kanye.rest

        {

"quote": "I don't expect to be understood at all."    }

    
    To get random Jokes  : https://v2.jokeapi.dev/joke/Any

           ENDPOINT - >  https://v2.jokeapi.dev/joke/ this is an endpoint for api.


    To use Weather details in your website : Openweather API

app.get("/", function(req, res){

    const weatherUrl = "https://api.openweathermap.org/data/2.5/weather?
                            q=Dhangadhi&appid={api_key}&units=metric";

    https.get(weatherUrl, function(response){
        response.on("data", function(data){ // get actual data from response
            const weatherData = JSON.parse(data);
            console.log(weatherData.weather[0].description);
                                                   //getting weather description
        });
    });
});


How to send multiple text response to the client in Express?

        > res.write("This is response 1");
        > res.write("This is response 2");
        > res.send();

Comments

Popular posts from this blog

Setup node framework | Express

calculator app using node express

React for Beginners