This topic describes how to install SDKs for Node.js and provides sample code.

Background information

  • Alibaba Cloud provides OpenAPI Explorer to simplify API usage. You can use OpenAPI Explorer to debug API operations and dynamically generate SDK sample code.
  • For more information about Resource Management API operations, see List of operations by function.

Installation

Run the following command to install the SDKs for Node.js and add dependencies to the package.json file:

$ npm install @alicloud/pop-core --save

For more information, see Get started.

You can download the installation packages of the SDKs for Node.js from the following links:

Example

The following example shows how to use Resource Management SDK for Node.js to call the CreateResourceAccount API operation. You can visit OpenAPI Explorer to debug other API operations and obtain their sample code.

const Core = require('@alicloud/pop-core');
// Construct an Alibaba Cloud client that is used to initiate requests.
// When you construct the client, specify your AccessKey ID and AccessKey secret.
var client = new Core({
  accessKeyId: '<accessKeyId>',
  accessKeySecret: '<accessSecret>',
  endpoint: 'https://resourcemanager.aliyuncs.com',
  apiVersion: '2020-03-31'
});
// Configure parameters.
var params = {
  "RegionId": "cn-hangzhou",
  "DisplayName": "<DisplayName>"
}

var requestOption = {
  method: 'POST'
};

client.request('CreateResourceAccount', params, requestOption).then((result) => {
  console.log(JSON.stringify(result));
}, (ex) => {
  console.log(ex);
})