I am new to backend programming and recently I've this problem that I cant receive any data from Open Map Weather API... I am trying to send my request with https/express in node.js... My API key and all the parameters are correct because everything went right in Postman... I would really appreciate it if somebody could help me with this... -Here is my code btw-
const exp = require("express");
const hhh = require("https");
const app = exp();
app.get("/", (req, res) => {
const url = "https://api.openweathermap.org/data/2.5/weather?q=London&appid=249e0887318ca2b591a7911fd54fe5fe";
hhh.get(url, (response) => {
console.log(response);
})
res.send("<h1>On Air 3000</h1>")
})
app.listen(3000, () => {
console.log("Listening on 3000");
})
From the official document [here] : https://nodejs.org/api/http.html#http_http_get_options_callback.
So
responseis an object of http.IncomingMessage class that allows you to get the response from API, it's not the result you see in the browser or Postman. You can see some code examples from the same document above.For your case, you can check the code below, I tested and it worked :)