3

I am running the following code on an express server and find my terminal prints an object with properties and values. However after this code is transpiled and run in a web browser I observe buffer of undefined. On the server, response.body is an empty object and response.text is a string. Should I try using request.pipe()?

My end goal is to make this request on both the server and client and retrieve a json object.

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);
    });

0 Answers0