簡體   English   中英

如何使用nodejs HTTP發出HTTP獲取請求?

[英]how to make an HTTP get request using nodejs HTTP?

我收到參考錯誤,因為我不能使用XMLHttpRequest。

有沒有辦法讓get http請求從mongodb中獲取所有數據?

http://localhost:3000/api/v1/posts

您可以嘗試使用此軟件包https://www.npmjs.com/package/request

var request = require('request');
request('http://www.google.com', function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body) // Show the HTML for the Google homepage. 
  }
})

暫無
暫無

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

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