English 中文(简体)
未在植被功能中读到文档数据的超级企业
原标题:Superagent not rendering read file data in .get function correctly

我正在走到一分钟。 JS course on Udemy and as one of the example for using an AP calls, we are being informed to use Superagent and calls the Dogs Chief AP. 我的代码与他在辅导中和出于某种奇怪原因的“数据”变量完全一样,正确读取了高科技档案中的数据,但当将APIC列入超级剂(URL)功能中时,RURL isnt的工作! 我不能说什么是错的。 请帮助!

如果代码样本在此不正确,则会发生职业关系。

const fs = require( fs )
const superagent = require( superagent )

fs.readFile(`${__dirname}/dog.txt`,  utf8 ,(err, data) => {
    console.log(data)
    superagent 
        .get(`https://dog.ceo/api/breed/${data}/mages/random ......)
        .end((err, res) => {  
            
            console.log(res.body.message)
    })
})

这是我在管理档案时在终点站得到的:

[nodemon] clean exit - waiting for changes before restart [nodemon] restarting due to changes... [nodemon] starting node index.js` hound

Breed not found (master breed does not exist) [nodemon] clean exit - waiting for changes before restart `

为什么在青春期正确阅读数据。 标识,但不在APIC中。

当我试图在“权责”职能之外管理内容时,我很奇怪地把它一半的《权利法》放在一个新的行文中:

http://dog.ceo/api/breed/hound

/mages/random ......

但是,当我把URL与“hound”硬编码成正文时,它就没有以这种方式出现,而是以如下方式正确表述:https://dog.ceo/api/breed/hound/images/random

请提供帮助。

我试图加以硬化,或将URL变成一个变数,造成不同的错误。 我期望这回头来回头来,像在教学中那样,对狗进行适当的反应。

问题回答

我认为,我照搬了你的问题。 如果是, txt用一条新行(正如我们通常希望结束档案)来结束,这条新线正被添加到ur中,并混淆。 如果你从狗中删除新线,或使用<代码>${data.trim()}。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签