本文整理汇总了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('');
});
示例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);
}
});
})
示例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);
}
});
});
示例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);
}
});
});
示例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')
示例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);
}
示例7: Promise
return new Promise((resolve, reject) => {
request.delete(uri)
.set('Accept', 'application/json')
.end((err, res) => err ? reject(err) : resolve(res.body));
});
示例8:
.then((response: any) => {
promiseResults.push(response);
return request.delete(`${PROVIDER_URL}/projects/2`);
})