Created
June 13, 2016 17:19
-
-
Save STRd6/21e346b5f55d1a45c1832f01ef94d8f6 to your computer and use it in GitHub Desktop.
Make requests to the Heroku API from the browser. Note accept and authorization headers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
APIGenerator = require "./api_generator" | |
{extend} = require "../source/util" | |
module.exports = (ajax) -> | |
requester = (path, options={}) -> | |
options = extend | |
url: path | |
method: "GET" | |
dataType: "json" | |
contentType: "application/json; charset=utf-8" | |
withCredentials: false | |
headers: | |
"Accept": "application/vnd.heroku+json; version=3" | |
"Authorization": "Bearer #{API_KEY}" | |
, options | |
ajax(options) | |
{get, put, patch, post} = api = APIGenerator("https://api.heroku.com", requester) | |
return api |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment