19 lines
611 B
JavaScript
19 lines
611 B
JavaScript
import { base, getToken } from "./_config";
|
|
|
|
export async function createToken({ username, password }) {
|
|
const res = await fetch(`${base}/auth/`, {
|
|
method: 'POST',
|
|
body: JSON.stringify({ username, password }),
|
|
headers: { "Content-Type": "application/json" }
|
|
})
|
|
if (!res.ok) throw await res.text()
|
|
return res.json()
|
|
}
|
|
|
|
export async function getInfoToken() {
|
|
const res = await fetch(`${base}/auth/`, {
|
|
headers: { "Authorization": `Bearer ${getToken()}`, "Content-Type": "application/json" }
|
|
})
|
|
if (!res.ok) throw await res.text()
|
|
return res.json()
|
|
} |