當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript request.put函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。