本文整理汇总了TypeScript中node-rest-client.Client.put方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Client.put方法的具体用法?TypeScript Client.put怎么用?TypeScript Client.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类node-rest-client.Client
的用法示例。
在下文中一共展示了Client.put方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Promise
return new Promise( ( resolve: (collectionInfo:{collectionId:string, postmanId:string} ) => void, reject: ( err?: any ) => void ) => {
try {
console.info("Update postman collection: ", collectionInfo.collectionId);
let client = new Client();
client.on( 'error', reject);
let args: any = {
headers: {
"Content-Type": "application/json",
"X-Api-Key": apiKey
},
data: { collection: collection }
};
collection.info._postman_id = collectionInfo.postmanId;
let url = `https://api.getpostman.com/collections/${collectionInfo.collectionId}`;
client.put( url, args, ( data: any, response: any ) => {
if ( response.statusCode >= 200 && response.statusCode < 300 ) {
resolve( {collectionId: data.collection.uid, postmanId: data.collection.id} );
} else {
let message = "Wrong response status " + response.statusCode + ", expected 2xx -> body:\n " + JSON.stringify(data);
reject( message );
}
} ).on( 'error', ( error: any ) => {
let message = "Failed to POST to " + url + " (" + error + ")";
reject( message );
} );
} catch ( e ) {
reject(e);
}
});