请问 NavigationService.ajax 如何请求小程序的云函数?有 demo 吗?
Closed this issue · 1 comments
anuxs commented
看代码请求后台 url 是用NavigationService.ajax:
`componentDidMount() {
NavigationService.ajax(Config.api.FooterHome, {}, {
onSuccess: (resp) => {
console.log(“”fetch data from backend,resp data:“”, resp)
this.setState({
pageTitle: resp.pageTitle,
})
},
})
}`
api url 的定义:
`
api: {
FooterHome: "viewHomepage/,
FooterMe: 'customerViewDashboard/',
Login: 'clientLogin/',
VerifyCode: 'sendVerifyCode/:mobile/',
OSSToken: 'customGetOssToken/',
Logout: 'logout/',
},
`
请问:我想要请求的后台是微信的云函数,该如何调用?:
`
Taro.cloud.callFunction({
name: “add”,
data: {
x: 1,
y: 2,
}
}).then(res => {
// output: res.result === 3
}).catch(err => {
// handle error
})
`
kala888 commented