|
@@ -1,27 +1,3 @@
|
|
|
-const applyParamsToUrl = (url, filter) => {
|
|
|
- if (filter) {
|
|
|
- let filteredEntities = ''
|
|
|
- if (url.indexOf('?') === -1) {
|
|
|
- url += '?'
|
|
|
- } else {
|
|
|
- url += '&'
|
|
|
- }
|
|
|
-
|
|
|
- Object.keys(filter).forEach(key => {
|
|
|
- filteredEntities += `${key}=${filter[key]}&`
|
|
|
- })
|
|
|
-
|
|
|
- if (filteredEntities.slice(-1) === '&') {
|
|
|
- filteredEntities = filteredEntities.slice(0, -1)
|
|
|
- }
|
|
|
-
|
|
|
- return url + filteredEntities
|
|
|
- }
|
|
|
-
|
|
|
- return url
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
export const state = () => ({
|
|
|
item: {},
|
|
|
items: {
|
|
@@ -44,7 +20,7 @@ export const actions = {
|
|
|
|
|
|
// /api/v1/blogs?filter[featured]=true
|
|
|
async fetchFeaturedBlogs({commit, state}, filter) {
|
|
|
- const url = applyParamsToUrl('/api/v1/blogs', filter)
|
|
|
+ const url = this.$applyParamsToUrl('/api/v1/blogs', filter)
|
|
|
const data = await this.$axios.$get(url)
|
|
|
if(data.isAxiosError === true){
|
|
|
console.log(data.data)
|