|
31 | 31 | ```js |
32 | 32 | const kscSdk = require('ksyun-sdk-node') |
33 | 33 |
|
34 | | -const Client = kscSdk.Iam.v20151101 |
| 34 | +const IamClient = kscSdk.Iam.v20151101 |
35 | 35 | const clientConfig = { |
36 | | - // 认证信息 |
37 | | - credential: { |
38 | | - secretId: '', |
39 | | - secretKey: '', |
40 | | - }, |
41 | | - // 产品地域 |
42 | | - region: "cn-beijing-6", |
43 | | - // 可选配置实例 |
44 | | - httpProfile: { |
45 | | - method: 'POST', // 请求方法 GET 或者 POST |
46 | | - timeout: 60, // 请求超时时间秒 |
47 | | - protocol: '', // 协议 http:// 或者 https:// |
48 | | - endpoint: '' // 接入点域名 如 iam.api.ksyun.com |
49 | | - }, |
| 36 | + // 认证信息 |
| 37 | + credential: { |
| 38 | + secretId: "KSYUN_SECRET_ID_HERE", |
| 39 | + secretKey: "KSYUN_SECRET_KEY_HERE", |
| 40 | + }, |
| 41 | + // 产品地域 |
| 42 | + region: "cn-beijing-6", |
| 43 | + // 可选配置实例 |
| 44 | + httpProfile: { |
| 45 | + method: 'POST', |
| 46 | + timeout: 60, // 请求超时时间秒 |
| 47 | + protocol: '', |
| 48 | + endpoint: 'iam.api.ksyun.com', |
| 49 | + }, |
50 | 50 | } |
51 | | -let client = new Client(clientConfig) |
| 51 | +let client = new IamClient(clientConfig) |
52 | 52 |
|
53 | 53 | /** |
54 | 54 | * client.request 参数 |
55 | 55 | * @param {string} apiAction 接口名 |
56 | 56 | * @param {object} data 参数 |
57 | 57 | */ |
58 | 58 |
|
59 | | -let apiAction = 'GetUser' |
| 59 | +let apiAction = 'ListUsers' |
60 | 60 | let data = { |
61 | | - "UserName": "test14" |
| 61 | + "MaxItems": 100 |
62 | 62 | } |
63 | 63 |
|
64 | 64 | client.request(apiAction, data) |
65 | | - .then(res => res.json()) |
66 | | - .then(data => { |
67 | | - console.log(JSON.stringify(data)) |
68 | | - }) |
69 | | - .catch(err => { |
70 | | - console.log(err) |
71 | | - }) |
| 65 | + .then(res => res.json()) |
| 66 | + .then(data => { |
| 67 | + console.log(JSON.stringify(data)) |
| 68 | + }) |
| 69 | + .catch(err => { |
| 70 | + console.log(err) |
| 71 | + }) |
72 | 72 | ``` |
73 | 73 |
|
74 | 74 | # 更多示例 |
|
0 commit comments