Extracted gateway for requests

This commit is contained in:
2026-01-18 00:30:29 +02:00
parent 2c021db505
commit 53aed96a05
6 changed files with 68 additions and 17 deletions
+5 -6
View File
@@ -1,18 +1,17 @@
<script setup>
import {ref} from "vue";
import {$user} from "./stores/user.js";
import * as gateway from "./lib/gateway.js";
const formData = ref({username: '', password: ''})
async function formSubmit() {
const url = `${import.meta.env.PUBLIC_SERVER_URL}/login`
const response = await fetch(
url,
const response = await gateway.request(
'/login',
{
method: 'POST',
mode: 'cors',
body: JSON.stringify(formData.value),
headers: {'Content-Type': 'application/json'}
cors: true,
body: JSON.stringify(formData.value)
}
)
if(response.status === 200) {