0👍
Assuming you already know how to fetch your data from your API, the final result would be something like this :
const getDataAndSplit = async () => {
const myData = await fetch(URL, etc etc); // get your data from your API
const rItems = []; // declaring empty array to fill it later
const sItems = []; // same
// looping over array of key/values
Object.entries(myData).forEach(([key, val]) => {
if (val.startsWith('r'))
rItems.push({label: key, value: val});
else
sItems.push({label: key, value: val});
}
return {rItems, sItems};
}
- [Vuejs]-How could I use materialize CSS CDN in nuxt.js?
- [Vuejs]-VueJS (resource, router and @websanova/vue-auth) login with JWT tokens refresh token error
Source:stackexchange.com