Skip to content

Instantly share code, notes, and snippets.

@seangates
Created February 28, 2017 05:06
Show Gist options
  • Save seangates/abfcfc460d4f62376df71043af9c382d to your computer and use it in GitHub Desktop.
Save seangates/abfcfc460d4f62376df71043af9c382d to your computer and use it in GitHub Desktop.
A simple way to use Knack requests in your Node.js app.
'use strict';
const rp = require('request-promise');
const _ = require('lodash');
class Knack {
constructor(config) {
this.knackBasePath = config.knackBasePath;
this.knackOptions = config.knackOptions;
}
knackRequest(uri) {
var wait = false;
var self = this;
if (uri === 'undefined') {
console.error('can\'t call knackRequest with undefined URI');
return;
}
uri = (uri && '/' + uri) || '';
this.knackOptions = _.extend(this.knackOptions, {
uri: this.knackBasePath + uri
});
return rp(this.knackOptions);
}
}
module.exports = Knack;
@seangates
Copy link
Author

Are there any Knack libraries in NPM? I wonder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment