mirror of
https://github.com/romancm/gamebrary
synced 2024-11-30 23:09:14 +00:00
load wikipedia article action
This commit is contained in:
parent
63816ff8a4
commit
7476b46429
1 changed files with 15 additions and 0 deletions
|
@ -17,6 +17,21 @@ export default {
|
|||
});
|
||||
},
|
||||
|
||||
LOAD_WIKIPEDIA_ARTICLE(context, articleTitle) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get(`https://en.wikipedia.org/w/api.php?origin=*&action=query&prop=extracts|images|links|linkshere|imageinfo&titles=${articleTitle}&inprop=url&format=json`)
|
||||
.then(({ data: { query } }) => {
|
||||
const pageIds = Object.keys(query.pages);
|
||||
|
||||
const article = pageIds.length
|
||||
? query.pages[pageIds[0]]
|
||||
: null;
|
||||
|
||||
resolve(article);
|
||||
}).catch(reject);
|
||||
});
|
||||
},
|
||||
|
||||
LOAD_BOARDS({ state, commit }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const db = firebase.firestore();
|
||||
|
|
Loading…
Reference in a new issue