Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is wx-promise-request in WeChat Mini Programs?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This "what is wx-promise-request in WeChat Mini Programs" article, the sample code in the article is very detailed, with a certain reference value, interested friends must refer to, for "what is wx-promise-request in WeChat Mini Programs", the editor sorted out the following knowledge points, please follow the pace of the editor to understand step by step, and then let's get into the topic.

Wx-promise-request is a solution of WeChat Mini Programs's wx.request method that does not support Promise and concurrency problems. If you only need to solve the concurrency problem, you can use my wx-queue-request

Solve the problem

Support for Promise (using the es6-promise library).

Manage the request queue to solve the problem that the maximum number of concurrency of request exceeds 10.

download

Since Mini Program does not support npm, you can just right-click to save the index.js file.

Use import {request} from'. / wx-promise-request';request ({url: 'test.php', data: {x:', y:',}, header: {'content-type':' application/json',},}) .then (res = > console.log (res)) .catch (error = > console.error (error)) APIsetConfig (object)

You can configure the behavior of wx-promise-request through setConfig.

Attribute description Type default value request function Functionwx.requestPromisePromise function Functiones6-promiseconcurrency maximum concurrency number10import {request, setConfig} from'. / wx-promise-request';import qcloud from'. / vendor/qcloud-weapp-client-sdk/index';import Promise from 'bluebird' / / customize requestsetConfig ({request: qcloud.request, / / use the request method Promise provided by qcloud, / / use bluebird as Promiseconcurrency: 5, / / limit the maximum number of concurrency to 5}) request ({url: 'test.php',}) .then (res = > console.log (res)) .catch (error = > console.log (error)) What does Mini Program mean? Mini Program is an application that can be used without download and installation. It can be used immediately by scanning a QR code or searching it. It is easy to operate and easy to spread. It can achieve seven major functions, such as message notification, offline code scanning, official account association, and so on. It is based on Wechat, similar to APP. You can use it whenever you want. After using it, you will leave without taking up memory.

The above is all the contents of the article "what is wx-promise-request in WeChat Mini Programs?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report