本文整理汇总了TypeScript中request.put函数的典型用法代码示例。如果您正苦于以下问题:TypeScript put函数的具体用法?TypeScript put怎么用?TypeScript put使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了put函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should return put', (done) => {
request.put(localBaseUrl + '/put', (err, res, body) => {
let data = assertResponse(err, res, body);
assert.equal(data, 'put');
done();
});
});
开发者ID:igabesz,项目名称:advanced-controllers,代码行数:7,代码来源:test-methods.ts
示例2: storeInternal
storeInternal(doc: { Id: string }, cb: (err: any, doc: any) => void ) {
var headers = {
"Content-Type": "application/json; charset=utf-8",
"Raven-Entity-Name": this.getEntityName(doc),
"If-Match": "00000000-0000-0000-0000-000000000000"
}
var id = doc.Id
if (doc["@metadata"]) {
headers = this.getHeadersFromMetadata(doc["@metadata"], headers)
delete doc["@metadata"].etag;
}
delete doc.Id;
var opts = {
url: "" + this.host + "databases/" + this.db + "/docs/" + id,
headers: headers,
body: this.serializer.stringify(doc)
};
request.put(opts, (error, response, body) => {
if (!error && response.statusCode === 201) {
var key = this.serializer.parse(body);
doc.Id = key.Key;
return cb(null, doc);
} else {
return cb(error || response, null);
}
});
}
开发者ID:Antares007,项目名称:AiPos,代码行数:30,代码来源:ravendb.ts
示例3: Promise
return new Promise((resolve, reject) => {
request.put(url, options, (error, response, body) => {
if (error) {
return reject(error);
}
resolve({response, body});
})
})
开发者ID:rajivnarayana,项目名称:wowza-nodejs-sdk,代码行数:8,代码来源:request-promise.ts
示例4: it
it('should handle RestErrors', (done) => {
request.put({
headers: { 'Accept': 'text/html' },
url: 'http://localhost:5674/accept/conflict',
}, function(error, response, body) {
expect(response.statusCode).to.eq(409);
done();
});
});
开发者ID:garyevari,项目名称:typescript-rest,代码行数:9,代码来源:test.spec.ts
示例5: it
it('should not authorize in PUT method', (done) => {
request.put('http://localhost:5674/authorization/methods/profile', {
headers: {
'Authorization': `Bearer ${generateJwt()}`
}
}, (error, response, body) => {
expect(response.statusCode).to.eq(403);
done();
});
});
开发者ID:thiagobustamante,项目名称:typescript-rest,代码行数:10,代码来源:authenticator.spec.ts
示例6: request
// Make a request to API.
// Syntax: .request(method, uri, [query], callback)
private request(method: string, uri: string, argsOrCallback?: any | RequestCallback, callback?: RequestCallback): void {
let args: any;
if (callback) {
args = argsOrCallback;
} else {
callback = argsOrCallback;
args = {};
}
let url = apiBaseUri + (uri[0] === "/" ? "" : "/") + uri;
if (method === "GET" || method === "DELETE") {
url += "?" + querystring.stringify(this.parseQuery(uri, args));
}
let options: request.Options = {
url: url,
method: method,
oauth: {
consumer_key: config.get("externalApp.consumer_key"),
consumer_secret: config.get("externalApp.consumer_secret"),
token: config.get("externalAppUser.token"),
token_secret: config.get("externalAppUser.token_secret"),
},
json: true,
};
let requestCallback = function (err: any, response: any, body: any): void {
if (!err && response.statusCode >= 400) {
err = new Error(body);
err.statusCode = response.statusCode;
err.responseBody = body;
err.statusMessage = http.STATUS_CODES[response.statusCode];
}
callback(err, body);
};
switch (method.toLowerCase())
{
case "get":
request.get(options, requestCallback);
break;
case "post":
request.post(options, requestCallback);
break;
case "put":
request.put(options, requestCallback);
break;
case "delete":
request.delete(options, requestCallback);
break;
}
};
开发者ID:gvprime,项目名称:microsoft-teams-sample-complete-node,代码行数:57,代码来源:ExampleOAuth1API.ts
示例7: Promise
return new Promise(resolve => {
request.put(
{
url: `${baseUrl}/${path}`,
headers: {
'Authorization': `Basic ${auth}`,
'Content-Type': 'application/json',
'User-Agent': 'request'
},
body: JSON.stringify(body)
},
(_err, resp, _body) => {
resolve(resp);
}
);
});
开发者ID:aurelia,项目名称:aurelia,代码行数:16,代码来源:ci-env.ts
示例8: function
function(resolve, reject) {
request.put({
url: config.baseurl + path,
headers: {
'Content-Type': 'application/json',
'clientID': clientId,
'msaID': msaId,
'accessToken': accessToken,
'nonce': uuidString
},
form: jsonBody
},
function(err,httpResponse,body){
resolve(body);
})
});
开发者ID:christoperhansaccenture,项目名称:smart-debug,代码行数:16,代码来源:sso.service.ts
注:本文中的request.put函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论