make get requesy to external server code example

Example 1: nodejs http get request to external server

const request = require("request");
const url = "<a href="https://my-json-server.typicode.com/edurekaDemo/noderequest/db">https://my-json-server.typicode.com/edurekaDemo/noderequest/db</a>";
request.get(url, (error, response, body) => {
let json = JSON.parse(body);
console.log(body);
});

Example 2: fetch data from external url nodejs

const fetch   = require('node-fetch');
 
app.get('/', function (req, res) {
    var url = 'https://api.darksky.net/forecast/<API KEY>/37.8267,-122.4233';
     
    fetch(url)
    .then(res => res.json())
    .then(data => {
        res.send({ data });
    })
    .catch(err => {
        res.send(err);
    });
});