So, I tried to run my application using nodemon then I am getting one error I was expecting it to work smoothly and don't throw me any error. When I remove the 'https' node module from the .js file then it works fine but as soon as I insert the 'https' module and use the https.get() method then I am getting this error.
This is the thing which I got-
[nodemon] starting
node app.js
Server started on port 3000 node:events:489 throw er; // Unhandled 'error' event ^
Error: unable to get local issuer certificate at TLSSocket.onConnectSecure (node:_tls_wrap:1560:34) at TLSSocket.emit (node:events:511:28) at TLSSocket._finishInit (node:_tls_wrap:977:8) at ssl.onhandshakedone (node:_tls_wrap:771:12) Emitted 'error' event on ClientRequest instance at: at TLSSocket.socketErrorListener (node:_http_client:495:9) at TLSSocket.emit (node:events:511:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY' }
Node.js v20.2.0 [nodemon] app crashed - waiting for file changes before starting...
const express = require("express");
const https = require("https");
const app = express();
app.get("/", function(req, res) {
const url = "https://api.openweathermap.org/data/2.5/weather?q=London,uk&APPID={API_ID}";
https.get(url, function(response){
console.log(response);
});
res.send("Server is up and running");
});
app.listen(3000, function() {
console.log("Server started on port 3000");
});