Registering Service Stub #59

Merged
tonitch merged 7 commits from tonitch/front/serviceInscription into master 2024-03-08 20:45:23 +01:00
2 changed files with 12 additions and 4 deletions
Showing only changes of commit e17ceab0e6 - Show all commits

View File

@ -1,4 +1,5 @@
import './assets/main.css'
import 'vue3-toastify/dist/index.css';
import { createApp } from 'vue'
import App from './Login.vue'

View File

@ -1,4 +1,5 @@
import { getCookie } from './utils.js'
import { getCookie } from '../utils.js'
import { toast } from 'vue3-toastify'
const restURL = import.meta.env.PROD ? "https://clyde.herisson.ovh/api" : "http://localhost:8080"
@ -28,7 +29,13 @@ async function _rest(endPoint, config){
let session_token = getCookie("session_token");
let headers = new Headers({'Authorization': session_token});
config['headers'] = headers;
return fetch(restURL + endPoint, config).then( e => e.json());
// TODO: Handle errors
return toast.promise(fetch(restURL + endPoint, config),
{
pending: config['pending'] != null ? config['pending'] : 'pending',
error: config['error'] != null ? config['error'] : 'Network Failure...',
success: config['success'] != null ? config['success'] : {render(res){
return res.ok ? "Success" : "error";
}},
})
.then( e => e.json()).catch( e => e );
}