當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript superagent.post函數代碼示例

本文整理匯總了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);
          }
        });
      });
  }
});
開發者ID:waffleio,項目名稱:gfm-task-list,代碼行數:26,代碼來源:development.ts

示例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");
            }
        })
開發者ID:dottgonzo,項目名稱:remote-auth,代碼行數:33,代碼來源:index.ts

示例3: saveSession

 saveSession(data:any) {
     return request
         .post(getSessionServiceUrl())
         .send(data)
         .then((res:any) => {
             return res.body
         });
 }
開發者ID:agarwalrounak,項目名稱:cbioportal-frontend,代碼行數:8,代碼來源:sessionServiceAPI.ts

示例4: Promise

 return new Promise((resolver, reject) =>
   agent.post(url).send(body).end((err, res) => {
     if (err) {
       reject(err);
     } else {
       resolver(res);
     }
   })
開發者ID:LachlanMcK,項目名稱:RAM,代碼行數:8,代碼來源:seed.script.ts

示例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());
		});
}
開發者ID:bensbigolbeard,項目名稱:universal-todomvc,代碼行數:9,代碼來源:client-events.ts

示例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));
		});
}
開發者ID:bensbigolbeard,項目名稱:universal-todomvc,代碼行數:9,代碼來源:client-events.ts

示例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());
		});
}
開發者ID:bensbigolbeard,項目名稱:universal-todomvc,代碼行數:9,代碼來源:client-events.ts

示例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
      })
}
開發者ID:eastmaels,項目名稱:v2.api.utopian.io,代碼行數:10,代碼來源:social_login.controller.ts


注:本文中的superagent.post函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。