1
0
Fork 0
freesewing/sites/shared/backend.mjs

25 lines
567 B
JavaScript
Raw Normal View History

2022-12-27 18:20:53 +01:00
import axios from 'axios'
2023-01-09 21:02:08 +01:00
import process from 'node: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()
}
}