search

Home  >  Q&A  >  body text

node.js - I want to request an interface using superagent

I want to use superagent to request this interfacehttp://hq.sinajs.cn/list=sh600138. How can I output the returned data on the console? Masters, I am still on it. Kindergarten please answer

漂亮男人漂亮男人2720 days ago806

reply all(1)I'll reply

  • 黄舟

    黄舟2017-06-19 09:09:53

    I took a look at your interface, because Content-Type:application/x-javascript; charset=GBK is not a buffer type, so it cannot be parsed directly, just convert it to buffer.

    const request = require('superagent');
    request
      .get('http://hq.sinajs.cn/list=sh600138')
      .buffer(true)
      .end((err, res) => {
          console.log(res.text);
      });

    reply
    0
  • Cancelreply