


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

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.

Atom editor mac version download
The most popular open source editor

Dreamweaver CS6
Visual web development tools

Dreamweaver Mac version
Visual web development tools