Skip to content

Instantly share code, notes, and snippets.

@jaredpalmer
Created December 16, 2015 19:19
Show Gist options
  • Save jaredpalmer/174b5bc3cae17a90fc77 to your computer and use it in GitHub Desktop.
Save jaredpalmer/174b5bc3cae17a90fc77 to your computer and use it in GitHub Desktop.
Quip Extraction Endpoint for Express API
/**
* POST Extract content from Quip document.
* @param {String} id Quip thread ID
*/
import Q from 'quip.js';
import cheerio from 'cheerio';
const Q = new Quip({
// Quip Access Token (required)
accessToken: "XXXXXX"
});
router.post('/quip', (req, res) => {
Q.th.getThread({id: req.body.url}, (err, results) => {
if (err) throw err;
const $ = cheerio.load(results.html, {ignoreWhitespace: true});
$('h1').remove();
const clean = $.html();
res.status(200).json({
html: clean,
title: results.thread.title
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment