不能读取forEach这个函数是什么情况!
来源:4-7 第四天 荡平永久素材接口-查询永久素材数量接口、获取永久素材列表接口
qq_十五人五_0
2016-07-19
else if(content ==='10'){
var picData =yield wechatApi.uploadMaterial('image',
__dirname+'/2.jpg',{}
);
var media = {
articles :[{
title : 'tututu',
thumb_media_id : picData.media_id,
author : 'pipi',
digest: '123',
show_cover_pic:1,
content:'123',
content_source_url:'https://cnodejs.org/'
}]
}
data = yield wechatApi.uploadMaterial('news',media,{});
data = yield wechatApi.fetchMaterial(data.media_id,'news',{});
console.log('data 123 '+data);
var items =data.news_item;
var news = [];
items.forEach(function(item){
news.push({
title:item.title,
description : item.digest,
picUrl : picData.url,
url : item.url
})
})
reply = news;
}控制台输出:
{ xml:
{ ToUserName: [ 'gh_326fbf1082ff' ],
FromUserName: [ 'oGZiawGth61Xg19zbUJxwyQrA5_g' ],
CreateTime: [ '1468920575' ],
MsgType: [ 'text' ],
Content: [ '10' ],
MsgId: [ '6308965830507425659' ] } }
{ ToUserName: 'gh_326fbf1082ff',
FromUserName: 'oGZiawGth61Xg19zbUJxwyQrA5_g',
CreateTime: '1468920575',
MsgType: 'text',
Content: '10',
MsgId: '6308965830507425659' }
data 123 [object Object]
TypeError: Cannot read property 'forEach' of undefined
at Object.exports.reply (/Users/s/Desktop/wechat/weixin.js:94:9)wechat.js上的代码已参考源代码,但是我想知道是为什么!代码上面的data是传下来的还是创建的对象,这个有点莫名了!console.log('data 123 '+data);输出的是 [object Object]结果对不对?老师求解
写回答
1回答
-
evilMuta
2016-07-26
errcode 是多少?是下面这个吗
{ errcode: 40007,
errmsg: 'invalid media_id hint: [nCYSFa0810e292]' }
032016-09-26
相似问题