From 42f76f614cf0c67d3bb292cd3a3b954008ea2080 Mon Sep 17 00:00:00 2001 From: ManjaroOne666 Date: Wed, 6 Feb 2019 12:45:22 +0000 Subject: [PATCH] axios and proxy modules --- TODO.md | 2 + nuxt.config.js | 11 +++++- package.json | 1 + pages/galleries.vue | 94 ++++++--------------------------------------- yarn.lock | 2 +- 5 files changed, 24 insertions(+), 86 deletions(-) diff --git a/TODO.md b/TODO.md index d95b002..ae7c713 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,6 @@ ## TODO +* Galleries - title not distinguishable on light images +* Galleries - navigatin icons not obvious enough with light background thumbs * API * mailer diff --git a/nuxt.config.js b/nuxt.config.js index 7c7b5c3..6cbe5c1 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -80,14 +80,21 @@ module.exports = { [ '@/assets/scss/_globals.scss' ] - ] - + ], + '@nuxtjs/proxy', ], + /* ** Axios module configuration */ axios: { // See https://github.com/nuxt-community/axios-module#options + proxy: true, + baseURL: 'http://192.168.0.5:3003', + }, + + proxy: { + '/api/v1/': 'http://192.168.0.5:8101' }, /* diff --git a/package.json b/package.json index 61dd0af..befbfd3 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ }, "dependencies": { "@nuxtjs/axios": "^5.3.6", + "@nuxtjs/proxy": "^1.3.1", "cross-env": "^5.2.0", "nuxt": "^2.0.0", "nuxt-buefy": "^0.2.1", diff --git a/pages/galleries.vue b/pages/galleries.vue index c93d1a8..56ce82c 100644 --- a/pages/galleries.vue +++ b/pages/galleries.vue @@ -1,5 +1,5 @@ @@ -13,6 +13,12 @@ export default { GalleryPage }, + data () { + return { + galleries: false, + } + }, + head () { return { title: 'My Galleries', @@ -24,89 +30,11 @@ export default { } }, - asyncData () { - return new Promise((resolve, reject) => { - resolve({ - galleries: [ - { title: 'Portraits', - id: 0, - featuredImage: 'https://marcleopold.isnet.uk/wp-content/uploads/2017/07/portraits-4-600x400.jpeg', - images: [ - { id: 1, thumbUrl: 'https://marcleopold.isnet.uk/wp-content/uploads/2017/07/portraits-4-600x400.jpeg', url: 'https://marcleopold.isnet.uk/wp-content/uploads/2017/07/portraits-4-1800x1200.jpeg' }, - { id: 2, thumbUrl: 'https://marcleopold.isnet.uk/wp-content/uploads/2017/07/portraits-3-600x400.jpeg', url: 'https://marcleopold.isnet.uk/wp-content/uploads/2017/07/portraits-3-1800x1200.jpeg' }, - { id: 3, thumbUrl: 'https://marcleopold.isnet.uk/wp-content/uploads/2017/07/portraits-2-480x600.jpg', url: 'https://marcleopold.isnet.uk/wp-content/uploads/2017/07/portraits-2-1800x2250.jpg' }, - { id: 7, thumbUrl: 'https://marcleopold.isnet.uk/wp-content/uploads/2017/07/portraits-8-390x600.jpeg', url: 'https://marcleopold.isnet.uk/wp-content/uploads/2017/07/portraits-8-1560x2400.jpeg' } - ] - }, - { title: 'Flowers', - id: 2, - featuredImage: 'https://marcleopold.isnet.uk/wp-content/uploads/2017/07/flowers-5-600x402.jpeg', - images: [ - { id: 4, thumbUrl: 'https://via.placeholder.com/400x300/ff0000/ffffff', url: 'https://via.placeholder.com/1920x1080/ff0000/ffffff?text=One0' }, - { id: 5, thumbUrl: 'https://via.placeholder.com/400x300/00ff00/ffffff', url: 'https://via.placeholder.com/1920x1080/00ff00/ffffff?text=One1' }, - { id: 6, thumbUrl: 'https://via.placeholder.com/400x300/0000ff/ffffff', url: 'https://via.placeholder.com/1920x1080/0000ff/ffffff?text=One2' }, - { id: 8, thumbUrl: 'https://via.placeholder.com/400x300/ffff00/ffffff', url: 'https://via.placeholder.com/1920x1080/ffff00/ffffff?text=One3' }, - { id: 9, thumbUrl: 'https://via.placeholder.com/400x300/ff00ff/ffffff', url: 'https://via.placeholder.com/1920x1080/ff00ff/ffffff?text=One4' }, - { id: 10, thumbUrl: 'https://via.placeholder.com/400x300/00ffff/ffffff', url: 'https://via.placeholder.com/1920x1080/00ffff/ffffff?text=One5' }, - { id: 11, thumbUrl: 'https://via.placeholder.com/400x300/ffffff/000000', url: 'https://via.placeholder.com/1920x1080/ffffff/000000?text=One6' }, - { id: 12, thumbUrl: 'https://via.placeholder.com/400x300/000000/ffffff', url: 'https://via.placeholder.com/1920x1080/000000/ffffff?text=One7' } - ] - }, - { title: 'The Longest Title for a Gallery That You Could Ever Imagine (Unless You Have a Really Good Imagination - And Then You Could Probably Think of a Really Big One)', - id: 3, - featuredImage: 'https://marcleopold.isnet.uk/wp-content/uploads/2017/07/music-4-600x400.jpg', - images: [ - { id: 13, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' }, - { id: 14, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' }, - { id: 24, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' }, - { id: 33, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' } - ] - }, - { title: 'Gallery Three', - id: 4, - featuredImage: 'https://via.placeholder.com/600x400', - images: [ - { id: 56, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' }, - { id: 3456, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' }, - { id: 947, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' }, - { id: 837, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' } - ] - }, - { title: 'Gallery Four', - id: 5, - featuredImage: 'https://via.placeholder.com/600x400', - images: [ - { id: 0, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' }, - { id: 1, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' }, - { id: 2, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' }, - { id: 3, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' } - ] - }, - { title: 'Gallery Five', - id: 6, - featuredImage: 'https://via.placeholder.com/600x400', - images: [ - { id: 0, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' }, - { id: 1, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' }, - { id: 2, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' }, - { id: 3, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' } - ] - }, - { title: 'Gallery Six', - id: 7, - featuredImage: 'https://via.placeholder.com/600x400', - images: [ - { id: 0, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' }, - { id: 1, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' }, - { id: 2, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' }, - { id: 3, thumbUrl: 'https://via.placeholder.com/400x300', url: 'https://via.placeholder.com/1920x1080' } - ] - }, - ] - }) - }) + async asyncData ({ $axios }) { + // TOOD catch errors + let { galleries } = await $axios.$get('/api/v1/galleries') + return { galleries } }, - } diff --git a/yarn.lock b/yarn.lock index 699b001..d9798cc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -968,7 +968,7 @@ consola "^2.3.0" node-fetch "^2.3.0" -"@nuxtjs/proxy@^1.3.0": +"@nuxtjs/proxy@^1.3.0", "@nuxtjs/proxy@^1.3.1": version "1.3.1" resolved "https://registry.yarnpkg.com/@nuxtjs/proxy/-/proxy-1.3.1.tgz#7d76179aff321491f126d6560434579a4dc7a89a" integrity sha512-agcTJVRCY0XfZcGV573bdIQLsg9fr5p6zikpxtUzR3xywdUBJ+JMKAiz3ew15bOZGK8lVS8u/PBmZ33iEhr3rg==