当前位置: 首页>>代码示例>>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;未经允许,请勿转载。