上个帖子已经问了这个问题,这个帖子可以关闭,避免重复提问了。
云开发的返回值有问题,如果代码提交方式有问题还望告知// 云函数入口函数 exports.main = async (event, context) => { let type = event.type let openId = event.userInfo.openId let { data } = await db.collection('posts').where({ _openid: openId }).orderBy('_id', 'desc').get() let promiseArr = data.map(item => db.collection('users').where({ _openid: item._openid }).limit(0).get()) let res = await Promise.all(promiseArr) for (let i = 0; i < res.length; i++) { data[i].userInfo = res[i].data[0].userInfo } return { data } } // 返回值如下 { errMsg: "cloud.callFunction:ok", result: { errorCode: 200, errorMessage: "{"data":[{"_id":"W8RBVJ25dhqgLEN9","_openid":"oMoT64r-dhGxPUUghCP0uXD9Nmgw","content":[{"type":1,"value":"阿斯蒂芬"},{"type":2,"value":["cloud://test-85938f.c341-test-85938f/post/80a37f7b-ac51-4472-81e9-37ac187b0921.jpg","cloud://test-85938f.c341-test-85938f/post/0f605f0c-6056-4f17-b310-0af8f87f5ecc.jpg"]}],"createdAt":{"$date":1539588436891},"title":"发帖,测试时间","views":12,"userInfo":{"avatarUrl":"https://wx.qlogo.cn/mmopen/vi_32/dxyAhb1HVjwN8gwBFSauvFbqF0cVJV0Vtw32CZHXDUfrQkYD6lFp5GibnoicBEscDRp3ia4JEicpdT1f0dsicdTUtQQ/132","city":"Shenzhen","country":"China","gender":1,"language":"zh_CN","nickName":"友友✨","province":"Guangdong"}},{"_id":"W8BxqJ25dhqgIjxO","_openid":"oMoT64r-dhGxPUUghCP0uXD9Nmgw","content":[{"type":2,"value":["cloud://test-85938f.c341-test-85938f/post/8adc90f6-b66a-4071-86c4-6f7ffc51923b.jpg","cloud://test-85938f.c341-test-85938f/post/4172b680-3ed3-458a-816f-7af344051dd9.jpg"]}],"createdAt":{"$date":1539338664702},"title":"人生得意须尽欢,莫使金樽空对月","views":13,"userInfo":{"avatarUrl":"https://wx.qlogo.cn/mmopen/vi_32/dxyAhb1HVjwN8gwBFSauvFbqF0cVJV0Vtw32CZHXDUfrQkYD6lFp5GibnoicBEscDRp3ia4JEicpdT1f0dsicdTUtQQ/132","city":"Shenzhen","country":"China","gender":1,"language":"zh_CN","nickName":"友友✨","province":"Guangdong"}},{"_id":"W8BfQd2AWotkcqHJ","_openid":"oMoT64r-dhGxPUUghCP0uXD9Nmgw","content":[{"type":2,"value":["cloud://test-85938f.c341-test-85938f/post/0a8435d6-ef3c-48ab-b182-bc32f275da53.jpg","cloud://test-85938f.c341-test-85938f/post/f0da453b-fa73-49b5-bcea-2b46c5a069ca.jpg"]},{"type":1,"value":"明李贽《朋友篇》:“去华(潘去华)友朋之义最笃,故是《纂》(指《闇然堂类纂》)首纂笃友谊。” 清昭梿《啸亭杂录·顾总河》:“﹝顾琮﹞果于友谊,公之督河时,前督完颜伟病于署中,家属已先行,公为之守护汤药,旬日无倦。”邹韬奋《友谊与职权》:“友谊是天地间最宝贵的东西,深挚的友谊是人生"},{"type":2,"value":["cloud://test-85938f.c341-test-85938f/post/e4308ae5-955e-4979-9e70-4ab0c4918b33.jpg"]},{"type":1,"value":"廉颇闻之,肉袒负荆,因宾客至蔺相如门谢罪。曰:“鄙贱之人,不知将军宽之至此也。”卒相与欢,为刎颈之交。"}],"createdAt":{"$date":1539333951629},"title":"友谊以亲密为核心成分,亲密性也就称为衡量友谊程度的一个重要指标,亲密度达到一定程度后即使这份友谊因事淡化,这份美好的记忆也会终生珍藏在“永恒的”回忆中,当再次重逢时它也会由怀旧中寻回,这种情感才能被称为“永恒的”友谊。\n罗杰斯(Rogers,1985)对这种亲密性作了三点概括:\n","views":7,"userInfo":{"avatarUrl":"https://wx.qlogo.cn/mmopen/vi_32/dxyAhb1HVjwN8gwBFSauvFbqF0cVJV0Vtw32CZHXDUfrQkYD6lFp5GibnoicBEscDRp3ia4JEicpdT1f0dsicdTUtQQ/132","city":"Shenzhen","country":"China","gender":1,"language":"zh_CN","nickName":"友友✨","province":"Guangdong"}},{"_id":"W8AUQZ25dhqgIUJK","_openid":"oMoT64r-dhGxPUUghCP0uXD9Nmgw","content":[{"type":2,"value":["cloud://test-85938f.c341-test-85938f/post/bca33b00-2bef-4ff6-9daa-523c009419f6.jpg"]},{"type":1,"value":"😀😁😂😄😅😃😇"}],"createdAt":{"$date":1539314753775},"title":"美女哈哈哈哈","views":1,"userInfo":{"avatarUrl":"https://wx.qlogo.cn/mmopen/vi_32/dxyAhb1HVjwN8gwBFSauvFbqF0cVJV0Vtw32CZHXDUfrQkYD6lFp5GibnoicBEscDRp3ia4JEicpdT1f0dsicdTUtQQ/132","city":"Shenzhen","country":"China","gender":1,"language":"zh_CN","nickName":"友友✨","province":"Guangdong"}},{"_id":"W8ATXp25dhqgIUAU","_openid":"oMoT64r-dhGxPUUghCP0uXD9Nmgw","content":[{"type":1,"value":"跑啊跑"},{"type":2,"value":["cloud://test-85938f.c341-test-85938f/post/28fb55c1-2765-4277-9c90-2b9384c168ad.jpg"]},{"type":1,"value":"开车去浪"},{"type":2,"value":["cloud://test-85938f.c341-test-85938f/post/82eb3c8a-6354-4a23-bd83-2f0951c7583f.jpg","cloud://test-85938f.c341-test-85938f/post/5cac40a0-3c7d-4cda-8206-7495bece4381.jpg"]},{"type":1,"value":"哈哈啊哈哈哈"}],"createdAt":{"$date":1539314526799},"title":"撸啊撸","views":1,"userInfo":{"avatarUrl":"https://wx.qlogo.cn/mmopen/vi_32/dxyAhb1HVjwN8gwBFSauvFbqF0cVJV0Vtw32CZHXDUfrQkYD6lFp5GibnoicBEscDRp3ia4JEicpdT1f0dsicdTUtQQ/132","city":"Shenzhen","country":"China","gender":1,"language":"zh_CN","nickName":"友友✨","province":"Guangdong"}},{"_id":"W78dhd2AWotkcAvM","_openid":"oMoT64r-dhGxPUUghCP0uXD9Nmgw","content":[{"type":1,"value":"啊手动阀手动阀"},{"type":2,"value":["cloud://test-85938f.c341-test-85938f/post/24d4de2a-d8b3-424f-9036-19898c1b6956.jpg","cloud://test-85938f.c341-test-85938f/post/f1b7dfc6-5f83-4a58-82d5-f606af593369.png","cloud://test-85938f.c341-test-85938f/post/f818ac1f-a1e1-4947-8da8-53bb470ec1eb.jpg"]}],"createdAt":{"$date":1539251587635},"title":"我的帖子","views":1,"userInfo":{"avatarUrl":"https://wx.qlogo.cn/mmopen/vi_32/dxyAhb1HVjwN8gwBFSauvFbqF0cVJV0Vtw32CZHXDUfrQkYD6lFp5GibnoicBEscDRp3ia4JEicpdT1f0dsicdTUtQQ/132","city":"Shenzhen","country":"China","gender":1,"language":"zh_CN","nickName":"友友✨","province":"Guangdong"}},{"_id":"W78WSd2AWotkb_oA","_openid":"oMoT64r-dhGxPUUghCP0uXD9Nmgw","content":[{"type":1,"value":"sdf"},{"type":2,"value":["cloud://test-85938f.c341-test-85938f/post/523bbd25-878e-47eb-9b00-a580916ef141.jpg","cloud://test-85938f.c341-test-85938f/post/b7a78de5-9883-4fd6-b9c8-4d210ff113fe.jpg"]},{"type":1,"value":"asdfsssssssssssssss"},{"type":2,"value":["cloud://test-85938f.c341-test-85938f/post/8cfe9457-b3b7-4f9d-ac7f-e52cf81bc1b2.jpg","cloud://test-85938f.c341-test-85938f/post/edbdcbf9-ada5-4054-83d1-1861b4ed82a9.jpg"]}],"createdAt":{"$date":1539294803000},"title":"xin","userInfo":{"avatarUrl":"https://wx.qlogo.cn/mmopen/vi_32/dxyAhb1HVjwN8gwBFSauvFbqF0cVJV0Vtw32CZHXDUfrQkYD6lFp5GibnoicBEscDRp3ia4JEicpdT1f0dsicdTUtQQ/132","city":"Shenzhen","country":"China","gender":1,"language":"zh_CN","nickName":"友友✨","province":"Guangdong"}}]}" } }
2018-10-16太让人惊喜了吧,找了半天问题,才发现是云函数返回结构问题....... 现在关心的是后面还会不会改回来,如果能确定就用一种数据结构也还能接受.......
云函数返回值结构改了?云函数返回值结构改了? { errMsg: "cloud.callFunction:ok" requestID:"xxxxxxxxxxxxx" result: { errorCode: 200 errorMessage: "data" } } 以前是 { errMsg: "cloud.callFunction:ok" requestID:"xxxxxxxxxxxxx" result: "data" } 这样的啊啊啊啊 这么任性吗? 已恢复
2018-10-16同,本地开发工具模拟器中请求接口成功,预览或者真机调试就报楼主那个错。奇怪的是发布线上后部分手机请求接口成功,部分手机请求接口失败。
小程序数据接口远程调用出错。调不出数据,Provisional headers are shown Accept-Encoding: gzip charset: utf-8 content-type: application/json User-Agent: Mozilla/5.0 (Linux; Android 6.0.1; 1605-A01 Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 MQQBrowser/6.2 TBS/044109 Mobile Safari/537.36 MicroMessenger/6.6.7.1321(0x26060739) NetType/4G Language/zh_CN MicroMessenger/6.6.7.1321(0x26060739) NetType/4G Language/zh_CN 正常浏览器访问这域名网址又正常。,求解一下。
2018-09-19