gancio-upstream/plugins/api.js

36 lines
771 B
JavaScript
Raw Normal View History

2020-10-17 00:41:21 +02:00
export default ({ $axios, store }, inject) => {
const api = {
/**
* Get events
2020-11-13 00:13:44 +01:00
*
2020-10-17 00:41:21 +02:00
* filter: {
* start_datetime: unix_timestamp (default now)
* end_datetime: unix_timestamp
* tags: [tag, list],
* places: [place_id],
* limit: (default )
* }
2020-11-13 00:13:44 +01:00
*
2020-10-17 00:41:21 +02:00
*/
async getEvents (params) {
try {
2020-11-13 00:13:44 +01:00
const events = await $axios.$get('/events', {
params: {
start: params.start,
end: params.end,
places: params.places && params.places.join(','),
tags: params.tags && params.tags.join(',')
}
})
2020-10-17 00:41:21 +02:00
return events
} catch (e) {
console.error(e)
return []
}
}
}
inject('api', api)
2020-11-13 00:13:44 +01:00
}