Skip to content

Commit

Permalink
Using fetch to make direct request to data
Browse files Browse the repository at this point in the history
  • Loading branch information
chrism committed Jun 10, 2018
1 parent 9905423 commit ce7f7bd
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"ember-data": "~3.1.1",
"ember-decorators": "^2.1.0",
"ember-export-application-global": "^2.0.0",
"ember-fetch": "^5.0.0",
"ember-glimmer-component": "^0.4.1",
"ember-load-initializers": "^1.1.0",
"ember-maybe-import-regenerator": "^0.1.6",
Expand Down
10 changes: 10 additions & 0 deletions public/api/tomsters/1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"data": {
"id": 1,
"type": "tomster",
"attributes": {
"filename": "tomster",
"filetype": "png"
}
}
}
6 changes: 4 additions & 2 deletions src/ui/routes/application/route.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import Route from '@ember/routing/route';
import fetch from 'fetch';

export default class ApplicationRoute extends Route {
async model() {
await new Promise(resolve => setTimeout(resolve, 2000));
let response = await fetch('/api/tomsters/1');
let json = await response.json();

return { filename: "tomster", filetype: "png" };
return json["data"]["attributes"];
}
}
42 changes: 39 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ abbrev@1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"

abortcontroller-polyfill@^1.1.9:
version "1.1.9"
resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.1.9.tgz#9fefe359fda2e9e0932dc85e6106453ac393b2da"

accepts@~1.3.4, accepts@~1.3.5:
version "1.3.5"
resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.5.tgz#eb777df6011723a3b14e8a72c0805c8e86746bd2"
Expand Down Expand Up @@ -1431,7 +1435,7 @@ broccoli-sri-hash@^2.1.0:
sri-toolbox "^0.2.0"
symlink-or-copy "^1.0.1"

broccoli-stew@^1.2.0, broccoli-stew@^1.3.3:
broccoli-stew@^1.2.0, broccoli-stew@^1.3.3, broccoli-stew@^1.4.2:
version "1.5.0"
resolved "https://registry.yarnpkg.com/broccoli-stew/-/broccoli-stew-1.5.0.tgz#d7af8c18511dce510e49d308a62e5977f461883c"
dependencies:
Expand All @@ -1450,6 +1454,17 @@ broccoli-stew@^1.2.0, broccoli-stew@^1.3.3:
symlink-or-copy "^1.1.8"
walk-sync "^0.3.0"

broccoli-templater@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/broccoli-templater/-/broccoli-templater-2.0.1.tgz#2e001e45aeba7fa2eb9b19a54c9c61b741935799"
dependencies:
broccoli-persistent-filter "^1.4.3"
broccoli-plugin "^1.3.0"
fs-tree-diff "^0.5.7"
lodash.template "^4.4.0"
rimraf "^2.6.2"
walk-sync "^0.3.2"

broccoli-uglify-sourcemap@^2.1.1:
version "2.2.0"
resolved "https://registry.yarnpkg.com/broccoli-uglify-sourcemap/-/broccoli-uglify-sourcemap-2.2.0.tgz#2ff49389bdf342a550c3596750ba2dde95a8f7d4"
Expand Down Expand Up @@ -2389,6 +2404,19 @@ ember-export-application-global@^2.0.0:
dependencies:
ember-cli-babel "^6.0.0-beta.7"

ember-fetch@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/ember-fetch/-/ember-fetch-5.0.0.tgz#fc58980010d625e9d86d238cbaabe7803fdddcfa"
dependencies:
abortcontroller-polyfill "^1.1.9"
broccoli-concat "^3.2.2"
broccoli-merge-trees "^2.0.0"
broccoli-stew "^1.4.2"
broccoli-templater "^2.0.1"
ember-cli-babel "^6.8.2"
node-fetch "^2.0.0-alpha.9"
yetch "^0.0.1"

ember-glimmer-component@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/ember-glimmer-component/-/ember-glimmer-component-0.4.1.tgz#f79703da5e760a72ebbf2e8c14dc432260a66319"
Expand Down Expand Up @@ -3140,7 +3168,7 @@ fs-minipass@^1.2.5:
dependencies:
minipass "^2.2.1"

fs-tree-diff@^0.5.2, fs-tree-diff@^0.5.3, fs-tree-diff@^0.5.4, fs-tree-diff@^0.5.6:
fs-tree-diff@^0.5.2, fs-tree-diff@^0.5.3, fs-tree-diff@^0.5.4, fs-tree-diff@^0.5.6, fs-tree-diff@^0.5.7:
version "0.5.7"
resolved "https://registry.yarnpkg.com/fs-tree-diff/-/fs-tree-diff-0.5.7.tgz#315e2b098d5fe7f622880ac965b1b051868ac871"
dependencies:
Expand Down Expand Up @@ -4234,7 +4262,7 @@ lodash.support@~2.3.0:
dependencies:
lodash._renative "~2.3.0"

lodash.template@^4.2.5:
lodash.template@^4.2.5, lodash.template@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.4.0.tgz#e73a0385c8355591746e020b99679c690e68fba0"
dependencies:
Expand Down Expand Up @@ -4629,6 +4657,10 @@ no-case@^2.2.0:
dependencies:
lower-case "^1.1.1"

node-fetch@^2.0.0-alpha.9:
version "2.1.2"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.1.2.tgz#ab884e8e7e57e38a944753cec706f788d1768bb5"

node-int64@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
Expand Down Expand Up @@ -6273,3 +6305,7 @@ yargs@~3.10.0:
yeast@0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419"

yetch@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/yetch/-/yetch-0.0.1.tgz#76f1729b2c2c667e23c3c2da90472a4897eca004"

0 comments on commit ce7f7bd

Please sign in to comment.