我的loadMaterial方法 运行不下去
来源:4-7 第四天 荡平永久素材接口-查询永久素材数量接口、获取永久素材列表接口
快要坏掉的小海
2016-05-07
查了很久都没有解决,请老师帮我看看哪里出错了
Wechat.prototype.uploadMaterial = function(type,material,permanent){
var that = this
var form = {}
var uploadUrl = api.temporarty.upload
if (permanent){
uploadUrl = api.permanent.upload
_.extend(form,permanent) //继承
}
if (type === 'pic'){
uploadUrl = api.permanent.uploadNewsPic
}
if (type === 'news'){
uploadUrl = api.permanent.uploadNews
form = material
}
else{
form.media = fs.createReadStream(material)
}
return new Promise(function(resolve,reject){
that
.fetchAccessToken()
.then(function(data){
var url = uploadUrl + 'access_token=' + data.access_token
if (!permanent){
url += '&type='+ type
}
else{
form.access_token = data.access_token
}
var options = {
method: 'POST',
url: url,
json: true
}
if (type === 'news'){
options.body = form
}else{
options.formData = form
}
request(options).then(function(response){
var _data = response.body
console.log('_data')
console.log(_data)
console.log('***************')
if (_data){
resolve(_data)
}else{
throw new Error('Upload material fails')
}
})
})
})
}
console.log(_data) 不出任何数值
不懂原因出在哪里,求帮助
1回答
-
每日上传素材是有限额的,你超出限额了,要等到第二天来试试看了
012016-05-08
相似问题