第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何使用 Node.js 讀取外部文本文件?

如何使用 Node.js 讀取外部文本文件?

寶慕林4294392 2021-10-21 15:07:21
所以我正在嘗試讀取外部(如來(lái)自不同域的)文本文件,但我嘗試過(guò)的任何內(nèi)容都不起作用。通常發(fā)生的是響應(yīng)是undefined,或者根本沒(méi)有。這是我嘗試過(guò)的一件事:// package xmlhttprequest is installed// this was copy-pasted from some other stackoverflow questionvar XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;var txtFile = new XMLHttpRequest();txtFile.open("GET", "https://snappeathing282346239557829348747259837723489.000webhostapp.com/pin.txt", true);txtFile.onreadystatechange = function() {  if (txtFile.readyState === 4) {  // Makes sure the document is ready to parse.    if (txtFile.status === 200) {  // Makes sure it's found the file.      allText = txtFile.responseText;       lines = txtFile.responseText.split("\n"); // Will separate each line into an array    }  }}console.log(txtFile.send(null)) // Logs response to console我得到的回應(yīng)是undefined,我怎樣才能得到 123(123 是 txt 文件包含的內(nèi)容)而不是記錄undefined?
查看完整描述

2 回答

  • 2 回答
  • 0 關(guān)注
  • 197 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)