Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IDATT2106 Scrum Team 02
Frontend
Commits
e910ead7
Commit
e910ead7
authored
1 year ago
by
Ingrid Martinsheimen Egge
Browse files
Options
Downloads
Patches
Plain Diff
API
parent
b6ab096d
No related branches found
No related tags found
1 merge request
!21
Merge profilinnstillinger into main
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/stores/useFoodPreferenceStore.js
+21
-0
21 additions, 0 deletions
src/stores/useFoodPreferenceStore.js
src/util/API.js
+15
-0
15 additions, 0 deletions
src/util/API.js
with
36 additions
and
0 deletions
src/stores/useFoodPreferenceStore.js
0 → 100644
+
21
−
0
View file @
e910ead7
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
This diff is collapsed.
Click to expand it.
src/util/API.js
0 → 100644
+
15
−
0
View file @
e910ead7
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
();
});
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment