You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nx-guitar-school/apps/website/libs/api.ts

47 lines
1.0 KiB

import axios from "axios";
import * as _ from 'lodash';
import {environment} from "../environments/environment";
import {config} from "../config";
export type Inputs = {
email: string,
username: string,
password: string,
passwordConfirmation: string,
agreement: boolean,
newsletter: boolean,
}
export type LostPasswordInputs = {
email: string;
}
export type ResetPasswordInputs = {
password: string,
passwordConfirmation: string,
code: string
}
export const hasAvatar = (user) => {
return !_.isNil(user.avatar);
}
export const getBackendImg = (imageUrl: string) => {
return `${environment.strapiUrl}${imageUrl}`;
}
export const signUpRequest = async (inputs: Inputs) => {
try {
const registerResponse = await axios.post(`${environment.strapiApiUrl}/auth/local/register`, {
email: inputs.email,
password: inputs.password,
username: inputs.username,
newsletter: inputs.newsletter
});
return registerResponse.data;
} catch (err) {
return Promise.reject('Internal error');
}
}