This topic describes how to install Node.js SDK and provides an operation example.

Installation

You can use npm to install Node.js SDK.

npm install -S @alicloud/pop-core

Example

/*
  Usage: npm install -S @alicloud/pop-core
  powered by alinode (http://alinode.aliyun.com/)
*/

const Core = require('@alicloud/pop-core');
// Construct an Alibaba Cloud client to initiate a request.
// Set the access key ID and access key secret.
var client = new Core({
  accessKeyId: '<accessKeyId>',
  AccessKeysecret: '<accessSecret>',
  endpoint: 'https://sts.aliyuncs.com',
  apiVersion: '2015-04-01'
});

// Specify the Alibaba Cloud Resource Name (ARN) of the role.
var params = {
  'RoleArn': '<role-arn>',
  'RoleSessionName': 'session-name'
};

// Construct the "AssumeRole" request.
client.request('AssumeRole', params).then((result) => {
  console.log(result);
}, (ex) => {
  console.log(ex);
})
Note