From e6b7a013c32f89e9aeebae34da168df77abf2f09 Mon Sep 17 00:00:00 2001 From: Nathan Bergey Date: Sun, 8 Jul 2018 13:38:13 -0400 Subject: [PATCH] Test HTTP GET a bus real time data --- package.json | 3 ++- public/test_45_0.json | 30 ++++++++++++++++++++++++++++++ src/App.vue | 18 ++++++++++++++++-- src/main.js | 3 +++ 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 public/test_45_0.json diff --git a/package.json b/package.json index e21b631..ab24dc6 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "lint": "vue-cli-service lint" }, "dependencies": { - "vue": "^2.5.16" + "vue": "^2.5.16", + "vue-resource": "^1.5.1" }, "devDependencies": { "@vue/cli-plugin-babel": "^3.0.0-beta.15", diff --git a/public/test_45_0.json b/public/test_45_0.json new file mode 100644 index 0000000..68904fe --- /dev/null +++ b/public/test_45_0.json @@ -0,0 +1,30 @@ +{ + "bus": [ + { + "lat": "39.921711", + "lng": "-75.14846", + "label": "8448", + "trip": "352606", + "VehicleID": "8448", + "BlockID": "7603", + "Direction": "EastBound", + "destination": "Columbus Commons", + "late": 2, + "Offset": "0", + "Offset_sec": "21" + }, + { + "lat": "39.924904", + "lng": "-75.172501", + "label": "8032", + "trip": "352633", + "VehicleID": "8032", + "BlockID": "7602", + "Direction": "WestBound", + "destination": "29th-Snyder", + "late": 3, + "Offset": "0", + "Offset_sec": "19" + } + ] +} diff --git a/src/App.vue b/src/App.vue index 6958a44..eb02bbb 100644 --- a/src/App.vue +++ b/src/App.vue @@ -7,7 +7,13 @@

-

data go here

+ +

🚌 45

+
@@ -18,7 +24,15 @@ export default { name: 'app', data: function () { return { - now: new Date() + now: new Date(), + bus: [] + } + }, + methods: { + test: function () { + this.$http.get('/test_45_0.json').then(response => { + this.bus = response.body.bus + }) } }, created () { diff --git a/src/main.js b/src/main.js index fca74cf..e7c3575 100644 --- a/src/main.js +++ b/src/main.js @@ -1,5 +1,8 @@ import Vue from 'vue' import App from './App.vue' +import VueResource from 'vue-resource' + +Vue.use(VueResource); Vue.config.productionTip = false