From 0d47fe042140ec39b098fb2f7dd197c1d15482ad Mon Sep 17 00:00:00 2001 From: stephen grider Date: Sun, 5 Jul 2015 12:28:19 -0700 Subject: [PATCH] Flux - 8 - Implementing Fetch --- imgur-client/package.json | 3 ++- imgur-client/src/utils/api.jsx | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 imgur-client/src/utils/api.jsx diff --git a/imgur-client/package.json b/imgur-client/package.json index 1408a30..0b01ead 100644 --- a/imgur-client/package.json +++ b/imgur-client/package.json @@ -21,7 +21,8 @@ "react-router": "^1.0.0-beta2", "reactify": "^1.1.0", "vinyl-source-stream": "^1.1.0", - "watchify": "^2.4.0" + "watchify": "^2.4.0", + "whatwg-fetch": "^0.9.0" }, "devDependencies": {} } diff --git a/imgur-client/src/utils/api.jsx b/imgur-client/src/utils/api.jsx new file mode 100644 index 0000000..037e768 --- /dev/null +++ b/imgur-client/src/utils/api.jsx @@ -0,0 +1,13 @@ +var Fetch = require('whatwg-fetch'); +var rootUrl = 'https://api.imgur.com/3/'; +var apiKey = '430d6820d865788'; + +module.exports = { + get: function(url) { + return fetch(rootUrl + url, { + headers: { + 'Authorization': 'Client-ID ' + apiKey + } + }); + } +};