diff options
author | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2019-11-28 10:36:12 +0100 |
---|---|---|
committer | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2019-11-28 10:36:12 +0100 |
commit | 8da7dad19ed454831b63d51058dd22550b9ac10c (patch) | |
tree | 22e5f94070867453a16ec7c53329d3e0a941e7e3 /pages | |
parent | fbdce0b0a1cefb88c6bac247db04af25a43c284f (diff) | |
download | puszcza-8da7dad19ed454831b63d51058dd22550b9ac10c.tar.gz puszcza-8da7dad19ed454831b63d51058dd22550b9ac10c.zip |
Add database connection
Diffstat (limited to 'pages')
-rw-r--r-- | pages/punktacja.vue | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/pages/punktacja.vue b/pages/punktacja.vue index 5f810ed..c263e5e 100644 --- a/pages/punktacja.vue +++ b/pages/punktacja.vue @@ -11,7 +11,18 @@ import RankingList from '~/components/Ranking/RankingList' const FAUNA_KEY = 'fnADeP_U0uACC4Hruw9JvjexNsvB-V-QjI3wr8yH' const b64encodedSecret = Buffer.from(FAUNA_KEY + ':').toString('base64') -const FAUNA_REF = '250230903625744898' +const query = ` +{ + getPoints{data {points troop{name}}} +}` +const URL = 'https://graphql.fauna.com/graphql' +const FETCH_OPTIONS = { + method: 'POST', + headers: { + Authorization: `Basic ${b64encodedSecret}` + }, + body: JSON.stringify({ query }) +} export default { components: { @@ -26,11 +37,13 @@ export default { this.getScores() }, methods: { - getScores() { - this.scores = [ - { troop: 'Toop 1', points: 1 }, - { troop: 'Troop 2', points: 2 } - ] + async getScores() { + const r = await fetch(URL, FETCH_OPTIONS) + const { data } = await r.json() + this.scores = data.getPoints.data.map(({ points, troop }) => ({ + troop: troop.name, + points + })) } } } |