WeChat applet network request (GET request) details

Source: Internet
Author: User
This article mainly introduces detailed information about the small program network request (GET request). If you need it, refer to the next article. it mainly introduces the small program network request (GET request) for more information, see

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 following is the GET request code:

// 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 ,})}})}})

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!

The above is a detailed description of the small program network request (GET request). For more information, see other related articles in the first PHP community!

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.