本文整理匯總了TypeScript中superagent.post函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript post函數的具體用法?TypeScript post怎麽用?TypeScript post使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了post函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
$('.render-btn').click( () => {
const markdown = $('.source').val();
if (markdown.length) {
request
.post('https://api.github.com/markdown')
.set('Authorization', `Bearer ${GH_ACCESS_TOKEN}`)
.set('Content-Type', 'application/json')
.send({
mode: 'gfm',
text: markdown
})
.end((err, res) => {
if (err) {
console.error(err);
}
$('.output').html(res.text);
$('.container').gfmTaskList({
markdownContainer: '.source',
renderedContainer: '.output',
onUpdate: (updatedMarkdown: String) => {
console.log('onUpdate called:', updatedMarkdown);
}
});
});
}
});
示例2: reject
return new Promise<string>((resolve, reject) => {
if (o) {
if (o.user && o.password) {
if (_this.couchdb && _this.app_id) {
let couchdb: string;
couchdb = _this.couchdb;
superagent.post(_this.couchdb + "/getmachines").send({
username: o.user,
passw: o.password,
app_id: _this.app_id
}).end((err, res) => {
if (err) {
reject(err);
} else if (res && res.body && res.body.data && res.body.data.appdb) {
const obj = res.body;
obj.data.appdb.user = o.user;
obj.token = jwt.sign(obj.data.appdb, _this.secret)
resolve(obj)
} else {
reject("server error")
}
})
} else {
reject("no couchdbserver provided");
}
} else {
reject("provide credentials!");
}
} else {
reject("wrong params");
}
})
示例3: saveSession
saveSession(data:any) {
return request
.post(getSessionServiceUrl())
.send(data)
.then((res:any) => {
return res.body
});
}
示例4: Promise
return new Promise((resolver, reject) =>
agent.post(url).send(body).end((err, res) => {
if (err) {
reject(err);
} else {
resolver(res);
}
})
示例5: completeAll
export function completeAll() {
// Fire action on server
superagent
.post('/api/todos/all?type=COMPLETE_ALL')
.end(function postCb(err, response) {
// Fire action on client
store.dispatch(actions.completeAll());
});
}
示例6: deleteTodo
export function deleteTodo(id) {
// Fire action on server
superagent
.post('/api/todos/' + id + '?type=DELETE_TODO')
.end(function postCb(err, response) {
// Fire action on client
store.dispatch(actions.deleteTodo(id));
});
}
示例7: clearCompleted
export function clearCompleted() {
// Fire action on server
superagent
.post('/api/todos/all?type=CLEAR_COMPLETED')
.end(function postCb(err, response) {
// Fire action on client
store.dispatch(actions.clearCompleted());
});
}
示例8:
const request_facebook_token = (body) => {
return request
.post('https://graph.facebook.com/oauth/access_token')
.set('Content-Type', 'application/json')
.send({
client_id: process.env.UTOPIAN_SOCIAL_FACEBOOK_CLIENT_ID,
client_secret: process.env.UTOPIAN_SOCIAL_FACEBOOK_SECRET,
code: body.code, redirect_uri: body.redirectUri
})
}