File size: 859 Bytes
c5cf697
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { apiJson } from './http'

export function login(email, password) {
  return apiJson('/users/login', {
    method: 'POST',
    body: JSON.stringify({ email, password }),
    auth: false,
  })
}

export function signup({ email, password, full_name }) {
  const body = { email, password }
  if (full_name?.trim()) body.full_name = full_name.trim()
  return apiJson('/users', {
    method: 'POST',
    body: JSON.stringify(body),
    auth: false,
  })
}

export function refreshTokens(refresh_token) {
  return apiJson('/users/refresh', {
    method: 'POST',
    body: JSON.stringify({ refresh_token }),
    auth: false,
  })
}

export function getProfile() {
  return apiJson('/users/me', { auth: true })
}

export function updateProfile(body) {
  return apiJson('/users/me', {
    method: 'PATCH',
    body: JSON.stringify(body),
    auth: true,
  })
}