2022-12-27 18:20:53 +01:00
|
|
|
import axios from 'axios'
|
2023-01-09 21:37:05 +01:00
|
|
|
import process from 'process'
|
2022-12-27 18:20:53 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Helper methods to interact with the FreeSewing backend
|
|
|
|
*/
|
|
|
|
|
|
|
|
const backend = axios.create({
|
|
|
|
baseURL: process.env.NEXT_PUBLIC_BACKEND || 'https://backend.freesewing.org',
|
|
|
|
timeout: 3000,
|
|
|
|
})
|
|
|
|
|
|
|
|
export const signUp = async ({ email, language, startLoading, stopLoading }) => {
|
|
|
|
let result
|
|
|
|
try {
|
|
|
|
startLoading()
|
|
|
|
result = await backend.post('/signup', { email, language })
|
|
|
|
} catch (err) {
|
|
|
|
console.log({ err })
|
|
|
|
} finally {
|
|
|
|
if (result) console.log({ result })
|
|
|
|
stopLoading()
|
|
|
|
}
|
|
|
|
}
|