• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript axios.post函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中axios.post函数的典型用法代码示例。如果您正苦于以下问题:TypeScript post函数的具体用法?TypeScript post怎么用?TypeScript post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了post函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: test

    test("get current user", async () => {
        await axios.post(
            process.env.TEST_HOST as string,
            {
                query: loginMutation(email, password)
            },
            {
                withCredentials: true // saves cookie
            }
        );

        const response = await axios.post(
            process.env.TEST_HOST as string,
            {
                query: meQuery
            },
            {
                withCredentials: true
            }

        )
        
        expect(response.data.data).toEqual({
            me: {
                id: userId,
                email
            }
        });
    })
开发者ID:itaygolan,项目名称:GraphQL-Typescript-Server,代码行数:29,代码来源:me.test.ts


示例2:

    testSequence.forEach(async step => {
        let url = step.getUrl();
        if (!step.waitForResponse) {
            responsesPending.push(axios.post(url, step.data));
        }
        else {
            let response = await axios.post(url, step.data);

            if (step.data != response.data) {
                throw `Expected '${step.data}' but received '${response.data}'`;
            }
        }
    });
开发者ID:roberthardy,项目名称:rp,代码行数:13,代码来源:traceTest.ts


示例3: function

	$scope.initiateExport = function(mode: string){
		var appList;
		if (mode === "docsOnly") {
			appList = ["workspace","rack"];
		} else if (mode === "all") {
			appList = expected;
		} else if (mode === "apps") {
			appList = $scope.availableApps.filter(app => $scope.selectedApps[app]);
		}
		http.post('/archive/export', {'apps':appList}).then(function(res){
			$scope.loadingSpinner = true;
			setTimeout(function() {
				http.get('/archive/export/verify/' + res.data.exportId).then(function(status){
					window.location.href = '/archive/export/' + res.data.exportId;
					$scope.loadingSpinner = false;
					$scope.$apply();
				}).catch(function(){
					notify.error('archive.error');
					setTimeout(function() {
						window.location.reload();
					},3000);
				});
			},5000);
			$scope.loading = true;
			$scope.$apply();
		}).catch(function(){
			notify.error('export.already');
		})
	};
开发者ID:entcore,项目名称:entcore,代码行数:29,代码来源:app.ts


示例4: translate

export const handleRegister = (login, email, password, langKey = 'en') => ({
  type: ACTION_TYPES.CREATE_ACCOUNT,
  payload: axios.post('api/register', { login, email, password, langKey }),
  meta: {
    successMessage: translate('register.messages.success')
  }
});
开发者ID:gjik911,项目名称:git_01,代码行数:7,代码来源:register.reducer.ts


示例5: generateSqlFromTemplate

export async function generateSqlFromTemplate(dialect: SqlDialect, sqlTemplate: string, paramsObj: any = {}): Promise<string> {
    if (!isString(sqlTemplate))
        throwError( "adminExecuteSql(): параметр 'sqlTemplate' должен быть строкой");

    if (!isString(dialect))
        throwError( "adminExecuteSql(): параметр 'dialect' должен быть строкой");

    let req = {
        sessionId:appState.sessionId,
        windowId:appState.windowId,
        authToken:appState.authToken,
        dialect: dialect,
        sqlTemplate: sqlTemplate,
//        paramsObj: XJSON_stringify(paramsObj),
        paramsObj: paramsObj,
    };

    let response: any = await axios.post("api/admin/generateSqlFromTemplate", {xjson:XJSON_stringify(req)});

    if (response.data.error)
        throwError( response.data.error);
    else
        return response.data.sql;

    throw "fake";
}
开发者ID:KostiaSA,项目名称:BuhtaClient2019,代码行数:26,代码来源:generateSqlFromTemplate.ts


示例6: ok

 public ok(callback?: Callback<string[]>): void {
   const data: FormData = new FormData();
   data.append("attachment", this.attachment);
   const url = `${this.apiOptions.server}/attachment`;
   const header: { [key: string]: string } = {};
   for (const k in this.apiOptions.headers) {
     if (k.toLowerCase() !== "content-type") {
       header[k] = this.apiOptions.headers[k];
     }
   }
   Axios.post(url, data, {headers: header})
       .then((response) => {
         return response.data as string[];
       })
       .then((result) => {
         if (callback) {
           callback(null, result);
         }
       })
       .catch((e) => {
         if (callback) {
           callback(e);
         }
       });
 }
开发者ID:MaxLeap,项目名称:MaxIM-JavaScript,代码行数:25,代码来源:buildAttachment.ts


示例7: ok

  public ok(callback?: Callback<string>): Admin {
    const url = `${this.admin.options().server}/groups`;
    const data = {
      owner: this.owner,
      members: this.appends,
    };

    Axios.post(url, JSON.stringify(data), {headers: this.admin.options().headers})
        .then((response) => {
          return response.data as string;
        })
        .then((groupid) => {
          this.admin
              .setAttributes(this.attributes)
              .forGroup(groupid, (err) => {
                if (callback) {
                  if (err) {
                    callback(err);
                  } else {
                    callback(null, groupid);
                  }
                }
              });
        })
        .catch((e) => {
          if (callback) {
            callback(e);
          }
        });
    return this.admin;
  }
开发者ID:MaxLeap,项目名称:MaxIM-JavaScript,代码行数:31,代码来源:buildGroup.ts


示例8: ok

  public ok(callback?: Callback<string>): Admin {
    const op = this.admin.options();
    const url = `${op.server}/rooms`;
    const body = {
      members: this.appends,
    };

    const config = {headers: op.headers};
    Axios.post(url, JSON.stringify(body), config)
        .then((response) => {
          return response.data as string;
        })
        .then((roomid) => {
          const url2 = `${op.server}/rooms/${roomid}/attributes`;
          const postData = JSON.stringify(this.attributes);
          return Axios.post(url2, postData, {headers: op.headers})
              .then((ignore) => {
                return roomid;
              });
        })
        .then((roomid) => {
          if (callback) {
            callback(null, roomid);
          }
        })
        .catch((e) => {
          if (callback) {
            callback(e);
          }
        });
    return this.admin;
  }
开发者ID:MaxLeap,项目名称:MaxIM-JavaScript,代码行数:32,代码来源:buildRoom.ts


示例9: ok

 public ok(callback?: Callback<void>): Admin {
   let url = `${this.admin.options().server}/system`;
   if (this.receiver.id) {
     url += `/${this.receiver.id}`;
     switch (this.receiver.type) {
       case Receiver.GROUP:
         url += "?group";
         break;
       case Receiver.ROOM:
         url += "?room";
         break;
       default:
         break;
     }
   }
   Axios.post(url, JSON.stringify(this.message), {headers: this.admin.options().headers})
       .then((ignore) => {
         if (callback) {
           callback(null, null);
         }
       })
       .catch((e) => {
         if (callback) {
           callback(e);
         }
       });
   return this.admin;
 }
开发者ID:MaxLeap,项目名称:MaxIM-JavaScript,代码行数:28,代码来源:launcher.ts


示例10: function

export default async function(userId: string, appId: string, scopes: string[], config: IWebAppConfig): Promise<ITokenInfo | null> {

	let tokenResult: AxiosResponse<any>;
	tokenResult = await axios.post(`${config.apiBaseUrl}/auth/token/get`, {
		appId: appId,
		userId: userId,
		scopes: scopes
	}, { headers: { authorization: `bearer ${config.hostToken.accessToken}` }, validateStatus: () => true });
	// expect: status 200 or error token_not_found
	if (tokenResult.status != 200 && (tokenResult.status != 400 || tokenResult.data.error.reason != 'token_not_found')) {
		log('failed to request /auth/token/get');
		log('statusCode:', tokenResult.status);
		log('data:', tokenResult.data);
		throw new HttpError(500, { error: { reason: 'server_error' } });
	}

	if (tokenResult.status == 400) {
		return null;
	}

	return {
		appId: tokenResult.data.result.appId,
		userId: tokenResult.data.result.userId,
		scopes: tokenResult.data.result.scopes,
		accessToken: tokenResult.data.result.accessToken
	};
}
开发者ID:Frost-Dev,项目名称:Frost,代码行数:27,代码来源:getToken.ts



注:本文中的axios.post函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript axios.put函数代码示例发布时间:2022-05-25
下一篇:
TypeScript axios.patch函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap