-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify to supply API Key in header #2
Comments
That should be doable Some example I found If there is a lot of demand to add this, we can look into a way to make this configurable |
Off course feel free to submit a pull request |
hey @timdows can you please add the api key for json? I have the same issue as the OP. |
@bachoo786 @clombardozzi getJson: function(url) {
var self = this;
request({
url: url,
method: 'GET',
headers: {
'X-Mashape-Key': 'lM66qSxXHcmsh5qSfHLz5vvHrP7zp1Ra8ncjsnCDxETtwCYwJP'
}
}, function(error, response, body) {
if (!error && response.statusCode == 200) {
var json = JSON.parse(body);
// Send the json data back with the url to distinguish it on the receiving part
self.sendSocketNotification("MMM-JsonTable_JSON_RESULT", { url: url, data: json });
}
});
}, |
@timdows thanks. i have inserted the code above in node_helper.js but I still get the following error:
here is what I have in my config.js:
Can you please help mate? Thanks. |
@bachoo786 This might work, but it is a hack, result: https://github.com/timdows/MMM-JsonTable/blob/master/MMM-JsonTable.js#L61 if (this.config.arrayName) {
items = this.jsonData[this.config.arrayName]["all"];
} else {
items = this.jsonData;
} Config {
module: 'MMM-JsonTable',
position: 'top_right',
header: 'Test',
config: {
url: 'https://transportapi.com/v3/uk/train/station/hrw/2019-09-05/10:49/timetable.json?app_id=bc370f15&app_key=7afee0527e55b33e74960f092eb08d2a&destination=eus&operator=lm&train_status=passenger',
arrayName: 'departures',
keepColumns: ["destination_name", "mode", "aimed_arrival_time"]
}
}, |
@timdows thanks for this hack. I copied your config above and it works perfect. I am wondering why is the information not updating ? EDIT: I figured it out as the url that you have in your post is specific to 10:49 |
Hi, I'm totally new to this but I wanted to know how would I go about modifying this module to add in a API key in the header so I can pull in the json feed? Here is the request example I'm given that i'd like to use.
curl --get --include 'https://transloc-api-1-2.p.mashape.com/arrival-estimates.json agencies=yale&callback=call'
-H 'X-Mashape-Key: lM66qSxXHcmsh5qSfHLz5vvHrP7zp1Ra8ncjsnCDxETtwCYwJP'
-H 'Accept: application/json'
The text was updated successfully, but these errors were encountered: