


Introduction to the encapsulation of the WeChat applet request interface
This article mainly introduces the relevant information about the encapsulation example code of the WeChat applet request interface. Friends who need it can refer to
The encapsulation example code of the WeChat applet request interface
Encapsulation of the mini program request interface (essentially calling back the request callback function again)
module.exports.getData = function (url) { var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var method = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'POST'; var header = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }; return new Promise(function (resolve, reject) { wx.request({ url: url, data: data, method: method, header: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, success: function (res) { resolve(res) }, fail: function (res) { reject(res) } }) }) }
Calling method
var common = require("../../common/common.js") common.getData(postUrl) .then(function(data){ this.setData({ //.... }); console.log(data); });
The above is the entire content of this article. I hope it will be helpful to everyone’s study. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
Introduction to the WeChat Mini Program network request wx.request
Video API in the WeChat Mini Program Parse
The above is the detailed content of Introduction to the encapsulation of the WeChat applet request interface. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools
