本文整理汇总了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
})
}