課程
/前端開發
/小程序
/輕松入門微信小程序與云開發
老師,這個api接口應該是這樣嗎
2019-12-03
源自:輕松入門微信小程序與云開發 4-3
正在回答
這列沒有res, 改成 return htmlString,然后請重新上傳云函數。
then中的參數你寫成了htmlString,這應該是res?。?!
完整代碼如下:
// 云函數入口函數
exports.main = async (event, context) => {
// event.start = 4;
// event.count = 10;
console.log('event.start--> ', event.start, ' event.count--> ', event.count);
return rp(`http://api.douban.com/v2/movie/in_theaters?apikey=0df993c66c0c636e29ecbb5344252a4a&start=${event.start}&count=${event.count}`)
.then(res => {
console.log('請求成功:', res);
return res;
})
.catch(err => {
console.error('請求失?。?, err);
});
}
舉報
深入淺出微信小程序核心基礎與云開發,使你掌握小程序開發必備技能。
3 回答接口返回:result為null
3 回答result總是null怎么回事,是api接口不能用嗎
4 回答result又為空了,API接口有不可用了嗎?
4 回答result為null
1 回答result為null ?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2019-12-04
這列沒有res, 改成 return htmlString,然后請重新上傳云函數。
2019-12-03
then中的參數你寫成了htmlString,這應該是res?。?!
完整代碼如下:
// 云函數入口函數
exports.main = async (event, context) => {
// event.start = 4;
// event.count = 10;
console.log('event.start--> ', event.start, ' event.count--> ', event.count);
return rp(`http://api.douban.com/v2/movie/in_theaters?apikey=0df993c66c0c636e29ecbb5344252a4a&start=${event.start}&count=${event.count}`)
.then(res => {
console.log('請求成功:', res);
return res;
})
.catch(err => {
console.error('請求失?。?, err);
});
}