wx.request、wx.uploadFile等网络请求API都需要配置开发者服务器接口地址,而使用云开发服务都没有这些,请问如何实现呢?
需求场景:图书馆小程序中,用户点击“更多”时显示图书信息,默认显示20个。用户每次拉到底部,再请求20个数据并显示。
小程序云开发如何实现Ajax(wx.request)?How to implement Ajax (wx.request) in applet cloud development?
小程序云开发如何实现Ajax(wx.request)?wx.request、wx.uploadFile等网络请求API都需要配置开发者服务器接口地址,而使用云开发服务都没有这些,请问如何实现呢?
需求场景:图书馆小程序中,用户点击“更多”时显示图书信息,默认显示20个。用户每次拉到底部,再请求20个数据并显示。
wx. request、wx. UploadFile and other network request APIs need to configure the developer server interface address, which is not available when using cloud development services. How do you implement it? Demand scenario: in the library applet, when the user clicks "more", the book information is displayed, and 20 are displayed by default. Each time the user pulls to the bottom, another 20 data are requested and displayed.
回答:
需求场景:图书馆小程序中,用户点击“更多”时显示图书信息,默认显示20个。用户每次拉到底部,再请求20个数据并显示。
需求云开发本身就能实现,为什么要用wx.request、wx.uploadFile?
在小程序后台配置request和upload域名
可以使用request-promise