Extracted gateway for requests
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user