Skip to main content

Calling Regular Cloud Functions

CloudBase provides various SDKs and APIs for developers to call cloud functions, including Mini-Program SDK, JS SDK, Node SDK, HTTP API, etc., to meet the needs of different scenarios and platforms.

Call Methods Overview

Call MethodApplicable ScenariosFeatures
Mini-Program SDKWeChat Mini ProgramsNative support, automatically carries user identity
Web SDKBrowser environment, frontend applicationsSimple and easy to use, automatic authentication
Node.js SDKServer-side, inter-function callsSupports server-side calls, fully functional
HTTP APICross-language calls, third-party system integrationStandard REST API, supports all languages
HTTP Access ServiceDirect frontend access, custom domainSupports custom paths and domains, cross-domain access

Call Examples

WeChat Mini Programs can directly use the wx.cloud.callFunction API to call cloud functions without additional configuration.

// Basic call method
wx.cloud.callFunction({
name: 'hello-world',
data: {
name: 'CloudBase',
message: 'Hello from MiniProgram'
},
success: res => {
console.log('Call successful:', res.result);
},
fail: err => {
console.error('Call failed:', err);
}
});

💡 Tip: When mini-programs call cloud functions, they automatically carry the user's OPENID, which can be obtained in the cloud function through event.userInfo.openId.

Related Documentation