Skip to main content

Cloud Hosting

callContainer

1. Interface Description

Function: Invoke Cloud Hosting services

Interface declaration: callContainer(object: Object): Promise<Object>

2. Input Parameters

FieldTypeRequiredDescription
namestringYesCloud Hosting service name
methodstringNoHTTP request method
pathstringNoHTTP request path
headerRecord<string, string>NoHTTP request headers
dataobjectNoHTTP request body

3. Output Parameters

FieldTypeRequiredDescription
codestringNoStatus code, not returned if the operation is successful
messagestringNoError description
resultobjectNoHTTP response body data
requestIdstringNoRequest 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)
});