检测失败
来源:3-11 歌单数据去重
慕后端8441795
2020-06-25
{“errorCode”:1,“errorMessage”:“user code exception caught”,“stackTrace”:“Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token export\n at Object.module.exports.load (/var/runtime/node10/UserFunction.js:28:13)\n at Runtime.handleOnce (/var/runtime/node10/Runtime.engine.js:84:38)\n at Timeout.setTimeout [as _onTimeout] (/var/runtime/node10/Runtime.engine.js:43:12)\n at ontimeout (timers.js:436:11)\n at tryOnTimeout (timers.js:300:5)\n at listOnTimeout (timers.js:263:5)\n at Timer.processTimers (timers.js:223:10)”}
3回答
-
请问“检测失败”是什么意思呢?
从这个错误信息上看是语法错误。
012020-06-25 -
慕后端8441795
提问者
2020-06-25
// 云函数入口文件
const cloud= require( 'wx-server-sdk')
cloud. init()
const db=cloud.database()
const rp= require( 'request-promise')
const URL='http://musicapi.xiecheng.live/personalized'
const playlistCollection=db.collection('playlist')
// 云函数入口函数
exports.main= async function main(event, context) {
const list =await playlistCollection.get()
// const countResult=await playlistCollection.count()
const playlist= await rp(URL).then((res)=>{
return JSON.parse(res).result
})
const newData=[]
for(let i=0,len1=playlist.length; i<len1; i++){
let flag=true
for(let j=0,len2=list.data.length;j<len2;j++){
if(playlist[i].id===list.data[j].id){
flag=false
break
}
}
if(flag){
newData.push(playlist[i])
}
}
// console.log(playlist)
for(let i=0,len=newData.length;i<len;i++){
await playlistCollection.add({
data:{
...newData[i],
createTime:db.serverDate(),
}
}).then((res)=>{
console.log('插入成功')
}).catch((err)=>{
console.error('插入失败')
})
}
return newData.length
}
00 -
慕后端8441795
提问者
2020-06-25
就是云端测试失败
00
相似问题