replay.js
wechatApi.deleteMenu().then(function () {
return wechatApi.createMenu(menu)
})
.then(function (msg) {
console.log(msg);
})
---------------------------------------------------
wechat.js
Wechat.prototype.deleteMenu = function () {
var that = this;
return new Promise(function (resolve, reject) {
that
.fetchAccessToken()
.then(function (data) {————————————————————>报错then未定义,之前其他使用then的地方没有错误
var url = api.menu.delete + 'access_token=' + data.access_token;
request({"url": url, "json": true}).then(function (response) {
var _data = response["body"];
//console.log(response);
//return;
if (_data) {
resolve(_data);
} else {
throw new Error('deleteMenu fails');
}
}).catch(function (err) {
reject(err);
})
})
});
}