提问者:小点点

节点js:发送get请求、保存响应


剪辑过,我剪短了。

代码变量被赋值

首先需要用get请求触发php脚本,输出不应该保存“https://flower.nyaizhel.ml/fun/carbon/?code=”+code

然后,当上面的请求完成后,将get请求发送到“https://flower.nyaizhel.ml/fun/carbon/shorturl.php?short&code=”+code并将响应保存到一个变量,

对于https://flower.nyaizhel.ml/fun/carbon/shorturl.php?short&code=ii,它应该是6,请参阅url

我试着取,没有结果


共1个答案

匿名用户

您必须等待它作为文本:

const resultValue = await fetch(`https://flower.nyaizhel.ml/fun/carbon/shorturl.php?short&code=${code}`).then(res => res.text());
// (if code === ii, resultValue = "6")
let resultAsInt = parseInt(resultValue);