当前位置:网站首页>Wechat applet 8 cloud function
Wechat applet 8 cloud function
2022-07-19 15:12:00 【k55】
Wechat applet 1- The basics of applets , Installation and use of development tools
Wechat applet 2-WXSS,WXS
Wechat applet 3- Applet lifecycle and components
Wechat applet 4- Applet api
Wechat applet 5- Real machine test
Wechat applet 6- Development of cloud - Cloud database
Wechat applet 7- Cloud storage
1. Cloud functions
Cloud function is a piece of code running in the cloud , No need to manage servers , Write... In development tools 、 One click upload deployment to run back-end code .
1). Create cloud functions
Small program provides a dedicated function for the cloud call API, Developers can use it in cloud functions wx-server-sdk Provided getWXContext Method gets the context of each call (appid、openid etc. ), No need to maintain complex authentication mechanism , You can get the natural and trusted user login status (openid).
(1). Find... In the current folder ”cloudfunctions“ file -> Right click Select current environment

(2). newly build Node.js Cloud functions



// Cloud function entry file
const cloud = require('wx-server-sdk')
cloud.init()
// Cloud function entry function
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext()
return {
event,
openid: wxContext.OPENID,
appid: wxContext.APPID,
unionid: wxContext.UNIONID,
}
}
(3). Deploy cloud functions

2). Use cloud functions
wx.cloud.callFunction({
name: 'getUserInfo',
data: {
},
success: (res) => {
console.log(res)
}
})

边栏推荐
- 原始套接字
- Code Runner for VS Code,下载量突破 4000 万!支持超过50种语言
- 1. Basic concepts of DBMS
- Leetcode 1275. Find out the winner of tic tac toe
- ObjectARX -- implementation of custom circle
- 中断的分类
- SQL wrong questions set of Niuke brush questions
- Scheduled tasks, VIM directly creates and modifies users
- ICML2022 | 几何多模态对比表示学习
- 论文阅读 TEMPORAL GRAPH NETWORKS FOR DEEP LEARNING ON DYNAMIC GRAPHS
猜你喜欢
随机推荐
买股票开户应该选哪个证券公司?什么证券公司是更安全的
傅里叶变换的再理解
【xss靶场10-14】见参数就插:寻找隐藏参数、各种属性
Comparison of two virtual machines
Damn it, why is there less space on the USB flash drive? It's the EFI partition. Delete it
A - Trees on the level(树的层序遍历)
[microservice] microservice learning note 3: use feign to replace resttemplate to complete remote call
009 面试题 SQL语句各部分的执行顺序
How to bind process threads to CPU cores
微信小程序7-云存储
ICML2022 | 幾何多模態對比錶示學習
2. MySQL introduction
ZABBIX realizes the monitoring of redis
GYM103660L.Monster Tower 整体二分
Load Objective-C at runtime
session管理
State machine exercise
Practice of tDesign in vitest
UVA - 12096 The SetStack Computer
[code attached] how to realize handwritten digit recognition with hog+svm








