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 } }); })
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}'`; } } });
$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'); }) };
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') } });
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"; }
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); } }); }
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; }
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; }
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; }
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 }; }