3

我在快速服务器上运行以下代码,发现我的终端打印了一个带有属性和值的对象。但是,在此代码被转译并在 Web 浏览器中运行后,我观察到未定义的缓冲区。在服务器上,response.body是一个空对象并且response.text是一个字符串。我应该尝试使用 request.pipe() 吗?

我的最终目标是在服务器和客户端上都发出这个请求并检索一个 json 对象。

import request from 'superagent';


var url = "http://jsfiddle.net/api/user/walkerrsmith/demo/list.json";

request
    .get(url)
    .buffer(true)
    .end((err, response) => {
        let result = JSON.parse(response.text);
        console.log(result);
    });
4

0 回答 0