WeChat applet network request (GET request) details, Applet get

Source: Internet
Author: User

Network requests (GET requests) of applets are described in detail.

Applet network request GET

Network requests are essential in applet development. Today we will talk about the simplest requests. We will try to upload and download these requests in the future.

1. A small program can have only five network request connections at the same time.

This rule should be made to ensure the user experience. After all, it is a small program.

2. wx. request (OBJECT) parameter description:

The applet supports GET, POST, and other requests. You can set it using method.

The following is the GET Request Code:

<Span style = "font-size: 18px;"> // rate. js // obtain the application instance var app = getApp () Page ({data: {code: 'use', currencyF_Name: '', currencyT_Name:'', currencyF :'', currencyT: '', currencyFD: 1, exchange: 0, result: 0, updateTime:'',}, onLoad: function (options) {var that = this; // obtain the wx exchange rate. request ({url: "http://op.juhe.cn/onebox/exchange/currency? Key = My appkey & from = CNY & to = "+ code, success: function (res) {that. setData ({currencyF_Name: res. data. result [0]. currencyF_Name, currencyT_Name: res. data. result [0]. currencyT_Name, currencyF: res. data. result [0]. currencyF, currencyT: res. data. result [0]. currencyT, currencyFD: res. data. result [0]. currencyFD, exchange: res. data. result [0]. exchange, result: res. data. result [0]. result, updateTime: res. data. result [0]. updateTime,}) }}}) </span>

In the above Code, you only need to provide the URL. the onLoad function is started during page initialization, wx. res of success in request. data is the data obtained from the background.

The json data format obtained is as follows.

Json parsing does not need to be done by myself. I still need to use gson or fastjson to parse json when doing Android. This solves a lot of trouble for us.

Thank you for reading this article. I hope it will 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.