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&units=metric&appid={my ID}");
https.get(url, function (response) {
console.log(response)
})
res.send("server is up and running")
})
app.listen(3000, function () {
console.log("Server is runniong on port 3000.");
})
最近,我看到Au Angela的全栈web开发课程的一个讲座,我做了她做过的事情,但当我刷新localhost:3000时,我的命令行是空的。
她的命令行结果她的代码
在JavaScript中声明字符串时不要使用括号。试试这个:
const url = "https://api.openweathermap.org/data/2.5/weather?q=London&units=metric&appid={my ID}";