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

Background information

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 code provides an example on how to use Resource Management SDK for Node.js to call the CreateResourceAccount API operation. You can use OpenAPI Developer Portal 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: '<accessKeySecret>',
  endpoint: 'https://resourcemanager.aliyuncs.com',
  apiVersion: '2020-03-31'
});
// Specify request parameters. For more information about the parameters, see API Reference.
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);
})