Created
December 16, 2015 19:19
-
-
Save jaredpalmer/174b5bc3cae17a90fc77 to your computer and use it in GitHub Desktop.
Quip Extraction Endpoint for Express API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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