Cloud Hosting
callContainer
1. Interface Description
Function: Invoke Cloud Hosting services
Interface declaration: callContainer(object: Object): Promise<Object>
2. Input Parameters
Field | Type | Required | Description |
---|---|---|---|
name | string | Yes | Cloud Hosting service name |
method | string | No | HTTP request method |
path | string | No | HTTP request path |
header | Record<string, string> | No | HTTP request headers |
data | object | No | HTTP request body |
3. Output Parameters
Field | Type | Required | Description |
---|---|---|---|
code | string | No | Status code, not returned if the operation is successful |
message | string | No | Error description |
result | object | No | HTTP response body data |
requestId | string | No | Request ID, used for error troubleshooting |
Service execution errors will throw exceptions
4. Sample Code
import cloudbase from "@cloudbase/js-sdk";
//Initialize the SDK instance
const app = cloudbase.init({
env: "xxxx-yyy"
});
app
.callContainer({
name: 'helloworld',
method: 'POST',
path: '/abc',
header:{
'Content-Type': 'application/json; charset=utf-8'
},
data: {
key1: 'test value 1',
key2: 'test value 2'
},
})
.then((res) => {
console.log(res)
});