Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 2x | import Axios, {AxiosError, AxiosResponse} from "axios"; import {hostname, userPath} from "./api"; export interface IRegisterServerResponse { httpStatus: number, httpMessage: string outputMessage?: string } export const registerNewUser = (username: string, password: string, passwordConfirmation: string): Promise<IRegisterServerResponse> => { return new Promise((resolve, reject) => { const newUser = { username: username, password: password, confirmationPassword: passwordConfirmation } return Axios.post(hostname + userPath + '/register', newUser) .then((data: AxiosResponse<object>) => { console.log(data) const response: IRegisterServerResponse = { httpStatus: data.status, httpMessage: data.statusText } if (data.status === 201) { response.outputMessage = "User was successfully created." } resolve(response); }) .catch((error: AxiosError) => { console.log(error.response) const response: IRegisterServerResponse = { httpStatus: error.response!.status, httpMessage: error.response!.statusText, outputMessage: error.response!.data.message } reject(response); }) }) } |