node-qiniu icon indicating copy to clipboard operation
node-qiniu copied to clipboard

fetch方法参数url和url模块冲突

Open aofong opened this issue 7 years ago • 2 comments

Asset.prototype.fetch = function(url, callback) {
  var self = this
  return new Promise(function(resolve, reject) {
    callback = callback || noop;

    var path = util.format('/fetch/%s/to/%s', utils.safeEncode(url), self.entryUrl());
    var _url = url.format({
      protocol: 'http',
      hostname: config.vipUrl,
      pathname: path
    });

    var token = self.access_token.token(path, null);

    request({
      url: _url, 
      method: 'POST',
      headers: {
        'Authorization': token,
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    }, function(err, res, body) {
      if (err) {
        reject(err);
        return callback(err);
      }

      resolve();
      callback(null);
    });
  })
};
Asset.prototype.fetch = function(url, callback) {
var _url = url.format({ //此处url和参数url有冲突
      protocol: 'http',
      hostname: config.vipUrl,
      pathname: path
    });
}

aofong avatar Jun 05 '17 14:06 aofong

request({
      url: _url, 
      method: 'POST',
      headers: {
        'Authorization': token,
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    }, function(err, res, body) {
      if (err) {
        reject(err);
        return callback(err);
      }

      resolve();
      callback(null); //TODO body参数没有回传
    });

aofong avatar Jun 05 '17 14:06 aofong

Asset.prototype.token 
Asset.prototype.url //现在的是随机域名,方法要修改了
Fop.prototype.imageView //官方参数已变更imageView=>imageView2

aofong avatar Jun 05 '17 15:06 aofong