Skip to content
This repository was archived by the owner on Jul 3, 2019. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@ var Client = exports.Client = function Client(appKey) {
this.appKey = appKey
}

Client.prototype.query = function(input, cb) {
Client.prototype.query = function(input, options, cb) {
if(!this.appKey) {
return cb("Application key not set", null)
}

var uri = 'http://api.wolframalpha.com/v2/query?input=' + encodeURIComponent(input) + '&primary=true&appid=' + this.appKey

if(typeof options === 'function') {
cb = options;
options = {primary: true};
}

var query = '';
for(var i in options) {
query += '&' + i + '=' + encodeURIComponent(options[i]);
}

var uri = 'http://api.wolframalpha.com/v2/query?input=' + encodeURIComponent(input) + query + '&appid=' + this.appKey

request(uri, function(error, response, body) {
if(!error && response.statusCode == 200) {
Expand Down