当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript superagent.delete函数代码示例

本文整理汇总了TypeScript中superagent.delete函数的典型用法代码示例。如果您正苦于以下问题:TypeScript delete函数的具体用法?TypeScript delete怎么用?TypeScript delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了delete函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

  it('should DELETE', async () => {
    mock.use((req, res) => {
      expect(req.method()).to.eq('DELETE');
      expect(String(req.url())).to.eq('/');
      expect(req.body()).to.eq(null);
      return res.status(204).reason('No Content');
    });

    const res = await superagent.delete('/');

    expect(res.status).to.eq(204);
    // expect(res.statusText).to.eq('No Content');
    expect(res.header).not.to.have.property('content-length', '12');
    expect(res.text).to.eq('');
  });
开发者ID:jameslnewell,项目名称:xhr-mock,代码行数:15,代码来源:superagent.test.ts

示例2: function

 function(resolve : (jsonObject : IRemoveCompanyResponse ) => void,
          reject : (error : ActionError) => void) : void {
     request
         .delete( "/api/companies/" + data.company_id)
         .set("x-access-token", data.token)
         .end(function(error : Object, res : Response) : void {
             if (error) {
                 let actionError : ActionError = res.body;
                 reject(actionError);
             } else {
                 let removeCompanyResponse :
                     IRemoveCompanyResponse = res.body;
                 resolve(removeCompanyResponse);
             }
         });
 })
开发者ID:BugBusterSWE,项目名称:MaaS,代码行数:16,代码来源:companyAPIs.ts

示例3: function

 function(
     resolve : (jsonObj : IRemoveDatabaseResponse) => void,
     reject : (err : Object) => void) : void {
     request
         .delete("/api/companies/" + data.id_company
             + "/database/" + data.id_database)
         .set("Content-Type", "application/json")
         .set("x-access-token", token)
         .end(function(error : Object, res : Response) : void{
             if (error) {
                 let actionError : ActionError = res.body;
                 reject(actionError);
             } else {
                 let response : IRemoveDatabaseResponse = res.body;
                 resolve(response);
             }
         });
 });
开发者ID:BugBusterSWE,项目名称:MaaS,代码行数:18,代码来源:databaseAPI.ts

示例4: function

 function(
     resolve : (jsonObject : IRemoveProfileResponse) => void,
     reject : (error : ActionError) => void) : void {
     request
         .delete("/api/companies/" + data.company_id
             + "/users/" + data.user_id)
         .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 userRemoveProfile :
                     IRemoveProfileResponse = res.body;
                 resolve(userRemoveProfile);
             }
         });
 });
开发者ID:BugBusterSWE,项目名称:MaaS,代码行数:19,代码来源:userAPIs.ts

示例5: request

request('GET', '/search')
  .end(callback);

request
   .get('http://example.com/search')
   .end(callback);

request
  .head('/favicon.ico')
  .end(callback);

request
  .del('/user/1')
  .end(callback);

request
  .delete('/user/1')
  .end(callback);

request
  .delete('/user/1')
  .send()
  .end(callback);

request('/search')
  .end(callback);

// Setting header fields
request
  .get('/search')
  .set('API-Key', 'foobar')
  .set('Accept', 'application/json')
开发者ID:AlBlanc,项目名称:DefinitelyTyped,代码行数:32,代码来源:superagent-tests.ts

示例6: 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

示例7: Promise

 return new Promise((resolve, reject) => {
   request.delete(uri)
     .set('Accept', 'application/json')
     .end((err, res) => err ? reject(err) : resolve(res.body));
 });
开发者ID:nshahpazov,项目名称:shoes-front-end,代码行数:5,代码来源:APIUtils.ts

示例8:

 .then((response: any) => {
   promiseResults.push(response);
   return request.delete(`${PROVIDER_URL}/projects/2`);
 })
开发者ID:elliottmurray,项目名称:pact-js,代码行数:4,代码来源:pact.integration.spec.ts


注:本文中的superagent.delete函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。