Skip to content
Snippets Groups Projects
Commit e910ead7 authored by Ingrid Martinsheimen Egge's avatar Ingrid Martinsheimen Egge :cow2:
Browse files

API

parent b6ab096d
No related branches found
No related tags found
1 merge request!21Merge profilinnstillinger into main
import {API} from "@/util/API"
import { defineStore} from "pinia";
export const useFoodPreferenceStore = defineStore("foodPreference", {
state: () => {
return {
foodPreferences: [],
};
},
persist: {
storage: localStorage,
},
actions: {
fetchAllOptions() {
API.getFoodpreferences()
.then((foodPreferences) => {
this.foodPreferences = foodPreferences;
})
}
}
})
\ No newline at end of file
import axios from "axios";
export const API = {
/**
* Fetches all available foodpreference options
*/
getFoodpreferences(){
return axios.get(`${import.meta.env.VITE_BACKEND_URL}/foodpreferences`)
.then((response) => {
return response.data;
}).catch(() => {
throw new Error();
});
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment