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


TypeScript superagent.put函數代碼示例

本文整理匯總了TypeScript中superagent.put函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript put函數的具體用法?TypeScript put怎麽用?TypeScript put使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了put函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

            function(
                resolve : (jsonObject : IUpdate) => void,
                reject : (error : ActionError) => void) : void {
                request
                    .put("/api/companies/" + data.company_id + "/users/"
                        + data._id + "/credentials")
                    .send(
                        {   username: data.username,
                            password : encryptedPasswordOP,
                            newUsername: data.newUsername,
                            newPassword: encryptedPasswordNP
                        })
                    .set("Accept", "application/json")
                    .set("x-access-token", data.token)
                    .end(function(error : Object, res : Response) : void {
                        if (error) {
                            let actionError : ActionError = res.body;
                            reject(actionError);
                        } else {

                            let updateUserPasswordResponse :
                                IUpdate = res.body;
                            resolve(updateUserPasswordResponse);
                        }
                    });
            });
開發者ID:BugBusterSWE,項目名稱:MaaS,代碼行數:26,代碼來源:userAPIs.ts

示例2: reject

        return new Promise<any>((resolve, reject) => {
            if (_this.auth) {
                superagent.put(_this.couchdb + "/" + obj._id).set('Content-Type', 'application/json').send(JSON.stringify(obj)).auth(_this.auth.user, _this.auth.password).end((err, res) => {
                    if (err) {
                        reject(err);
                    } else {
                        obj._rev = JSON.parse(res.text).rev;
                        resolve(obj);
                    }
                })
            } else {
                superagent.put(_this.couchdb + "/" + obj._id).set('Content-Type', 'application/json').send(JSON.stringify(obj)).end((err, res) => {
                    if (err) {
                        reject(err);
                    } else {
                        obj._rev = JSON.parse(res.text).rev;
                        resolve(obj);
                    }
                })
            }

        })
開發者ID:dottgonzo,項目名稱:couch-node,代碼行數:22,代碼來源:index.ts

示例3: function

 function(resolve : (jsonObject : ICompanyResponse ) => void,
          reject : (error : ActionError) => void) : void {
     request
         .put("/api/companies/" + company_id)
         .set("x-access-token", token)
         .send(companyName)
         .end(function(error : Object, res : Response) : void {
             if (error) {
                 let actionError : ActionError = res.body;
                 reject(actionError);
             } else {
                 let updateCompanyResponse :
                     ICompanyResponse = res.body;
                 resolve(updateCompanyResponse);
             }
         });
 })
開發者ID:BugBusterSWE,項目名稱:MaaS,代碼行數:17,代碼來源:companyAPIs.ts

示例4: it

  it('should PUT', async () => {
    mock.use((req, res) => {
      expect(req.method()).to.eq('PUT');
      expect(String(req.url())).to.eq('/');
      expect(req.body()).to.eq(JSON.stringify({foo: 'bar'}));
      return res
        .status(200)
        .reason('Created')
        .header('Content-Length', '12')
        .body('Hello World!');
    });

    const res = await superagent.put('/').send({foo: 'bar'});

    expect(res.status).to.eq(200);
    // expect(res.statusText).to.eq('Created');
    expect(res.header).to.have.property('content-length', '12');
    expect(res.text).to.eq('Hello World!');
  });
開發者ID:jameslnewell,項目名稱:xhr-mock,代碼行數:19,代碼來源:superagent.test.ts

示例5: function

 function(
     resolve : (jsonObj : IDatabase) => void,
     reject : (err : Object) => void) : void {
     request
         .put("/api/companies/" + data.id_company +
             "/database/" + data.id_database)
         .set("Content-Type", "application/json")
         .set("x-access-token", token)
         .send(data)
         .end(function(error : Object, res : Response) : void{
             if (error) {
                 let actionError : ActionError = res.body;
                 reject(actionError);
             } else {
                 let response : IDatabase = res.body;
                 resolve(response);
             }
         });
 });
開發者ID:BugBusterSWE,項目名稱:MaaS,代碼行數:19,代碼來源:databaseAPI.ts

示例6: put

	/**
	 * Builds a HTTP PUT request for the provided `endpoint`.
	 *
	 * @hidden
	 * @param endpoint    The endpoint URI, relative to this server’s base URL. Must start with a `/`.
	 * @return A request object to `PUT` on `endpoint`.
	 */
	public put(endpoint: string): Http.Request {
		return Http.put(this.baseUrl + endpoint);
	}
開發者ID:jGleitz,項目名稱:isso-clientlib,代碼行數:10,代碼來源:IssoServer.ts

示例7: async

export let ajax: AjaxFunction = async (url, data, type = 0, ajaxType = 'get') => {

    //統一添加請求路徑
    if (url.indexOf('http') != 0) {
        url = config.requestUrl + url;
    }


    let ajaxRequest: superagent.SuperAgentRequest;
    let ajaxRecord: AjaxRecord = {
        url,
        time: new Date(),
        data,
        type,
        ajaxType
    };

    //創建請求
    switch (ajaxType) {
        case 'delete':
            ajaxRequest = superagent.delete(url);
            break;
        case 'put':
            ajaxRequest = superagent.put(url);
            break;
        case 'get':
            ajaxRequest = superagent.get(url);
            break;
        case 'post':
            ajaxRequest = superagent.post(url);
            break;
    }

    //創建請求數據
    if (data) {
        ajaxRequest = ajaxRequest.send(data);
    }

    //添加請求記錄 反向添加
    ajaxRecordArray.unshift(ajaxRecord);
    let typeFunctionValue = await typeFunctionArray[type](url, data, type, ajaxType, ajaxRecord);
    if (typeFunctionValue) {
        return typeFunctionValue;
    }

    let promiseFunction = (reslove, reject) => {
        //發送請求
        ajaxRequest.end((error, res) => {
            ajaxRecord.response = res;
            if (error) {
                errorMsg({
                    message: `請求錯誤!`,
                    description: 'status:${res.status}'
                });
                reject(ajaxRecord.responseDate);
            } else {
                try {
                    ajaxRecord.responseDate = JSON.parse(res.text);
                } catch (error) {
                    ajaxRecord.responseDate = {
                        status: 0,
                        data: res.text,
                        message: ''
                    };
                }
                reslove(ajaxRecord.responseDate);
            }
        })
    }


    return new Promise<AjaxData>(promiseFunction);
}
開發者ID:unclemake,項目名稱:axiba,代碼行數:73,代碼來源:index.ts

示例8:

 return Promise.fromCallback(callback => {
         return this.auth(put(this.papiUrl('/batches/' + this.currentBatchId +'/'))).end(callback);
     })
開發者ID:thomas-hilaire,項目名稱:spews-importer,代碼行數:3,代碼來源:PapiClient.ts


注:本文中的superagent.put函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。