Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

untitled notebook

node v6.17.1
version: 1.0.0
endpointsharetweet
const request = require('request'); const requestPromise = require("request-promise"); class Delivery { constructor(projectID, previewKey) { this.projectID = projectID; this.previewKey = typeof previewKey === 'undefined' ? null : previewKey; } }; Delivery.prototype.getContent = function(param, isPreview) { if (typeof param === 'undefined') { param = ''; } if (typeof isPreview === 'undefined') { isPreview = false; } var options = helper.getOptions(param, this.projectID, this.previewKey, isPreview); return helper.getRawData(options); }; var helper = { getRawData: (options) => { return requestPromise(options); }, getDeliveryUrl: (projectID, isPreview) => { if (isPreview) { return 'https://preview-deliver.kenticocloud.com/' + projectID + '/items'; } else { return 'https://deliver.kenticocloud.com/' + projectID + '/items'; } }, getOptions: (param, projectID, previewKey, isPreview) => { var options = { uri: helper.getDeliveryUrl(projectID, isPreview) + param, json: true }; if (isPreview && previewKey !== null) { options.headers = { Authorization: 'Bearer ' + previewKey } } return options; } }; var project = new Delivery('2548121d-cad8-4458-a910-5e4b54cb0956', 'ew0KICAiYWxnIjogIkhTMjU2IiwNCiAgInR5cCI6ICJKV1QiDQp9.ew0KICAidWlkIjogInVzcl8wdlVJVzkwTnRQSVNxNm1GSDN2ZFhiIiwNCiAgImVtYWlsIjogImhlbGxvQG1pbGFubHVuZC5jb20iLA0KICAicHJvamVjdF9pZCI6ICIyNTQ4MTIxZC1jYWQ4LTQ0NTgtYTkxMC01ZTRiNTRjYjA5NTYiLA0KICAianRpIjogInhrU1BLUjlzbzgxSV9rel8iLA0KICAidmVyIjogIjEuMC4wIiwNCiAgImdpdmVuX25hbWUiOiAiTWlsYW4iLA0KICAiZmFtaWx5X25hbWUiOiAiTHVuZCIsDQogICJhdWQiOiAicHJldmlldy5kZWxpdmVyLmtlbnRpY29jbG91ZC5jb20iDQp9.PpBh6wTk57e1_tPHzROiqWPTpr3IjrEoGN8J4rtfPIg'); project.getContent('?system.type=hello_world', true) .then(console.log) .catch(console.error);
Loading…

no comments

    sign in to comment