簡體   English   中英

Nodejs、nodemon 應用程序崩潰(里面的截圖)

[英]Nodejs, nodemon app crashed (screenshot inside)

不明白我的服務器和代碼有什么問題。 我正在通過教程並按照視頻中的方式完成所有操作,但仍然存在問題

圖片

似乎您正在使用 https 連接而不處理 TLS 證書傳遞。

這是一個代碼片段,使您無需配置證書即可訪問 openweathermap API。

const express = require('express')
const https = require('https')

const app = express()

app.get("/", function(req, res) {
    const url = "<openweathermap>"
    var options = require('url').parse( /**String*/ url );
    options.rejectUnauthorized = false;
    https.get(options, function(response) {
        console.log(response);
    }).on( 'error',function ( e ) {
        console.log(err);
    }).end();

    res.send("Sever up and running");
}

app.listen(3000, function(){
   console.log("Server running on port 3000";
}

我建議閱讀有關如何在 Node.JS 中為 HTTPS 設置證書的更多信息,請參閱此文檔。 更多細節。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM