【短文】await,async简单的使用方式
代码
async valid_name(name){
const invokeRes = await wx.serviceMarket.invokeService({
service: ‘wxee446d7507c68b11’,
api: ‘msgSecCheck’,
data: {
"Action": "TextApproval",
"Text": name
},
}).then(res => {
var EvilTokens = res\['data'\]\['Response'\]\['EvilTokens'\]
console.log(EvilTokens)
if (EvilTokens.length == 0){
console.log('内容合法')
return '111';
}else{
console.log('内容不合法')
return '0';
}
})
console.log(‘invokeRes’, invokeRes)
return invokeRes