WeChat applet wx. request (object) API details and instance code, wx. requestapi

Source: Internet
Author: User

Detailed description of the applet wx. request (object) API and instance code, wx. requestapi

Here, we use the API of the concentration camp to request data. If you are prompted that the URL domain name is invalid, configure it in the mp background and modify the asdebug. js code again. See the following figure.

Go to the asdebug. js File

When you enable the search keyword URL domain name, the invalid keyword indicates that the error message is annotated with two lines of code.

Main Methods:

Wxml

<Block wx: for-items = "{result}"> <view style = "width: 100%; height: 50rpx" ></view> <! -- Index is a subscript by default, and item is each item --> <text> entry {index} of Data {item. desc }}</text> <text> address {item. url }}</text> </block>

Js

Page ({data: {// text: "this is a Page" result: []}, onLoad: function () {var that = this; wx. request ({url: 'http: // gank. io/api/data/Android/30/1 ', method: 'get', success: function (res) {that. setData ({result: res. data. results}) }}, listenerButton: function (){}})

Thank you for reading this article and hope to help you. Thank you for your support for this site!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.