var http = require('http');
//var dataQueryUrl = `http://api.avatardata.cn/ChengYu/Search?key=${apikey}&keyWord=`;

function request(key, word, cb) {
  var options = {
    host: 'http://api.avatardata.cn',
    path: `/ChengYu/Search?key=${key}&keyWord=${word}`,
    port: '80',
    method: 'GET'
  };

  var callback = function(response) {
    var str = ''
    response.on('data', function (chunk) {
      str += chunk;
    });

    response.on('end', function () {
      cb(str);
    });
  }

  var req = http.request(options, callback);
  //This is the data we are posting, it needs to be a string or a buffer
  // req.write(JSON.stringify({
  //
  // }));
  req.end();
}

module.exports = request;
@@ -321,16 +321,21 @@
 unction(
+err, 
 response
@@ -334,24 +334,63 @@
 response) %7B%0A
+    if (err) %7B%0A      throw err;%0A    %7D%0A%0A
     var str 
@@ -499,24 +499,48 @@
 nction () %7B%0A
+      console.log(str);%0A
       cb(str

add error handler