當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。