SHARE
TWEET

Untitled

a guest Dec 11th, 2018 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ./routes/api/index.js
  2.  
  3. // the router is already using /api (see routes/index.js), so this is actually a post to /api/
  4. router.post('/', function(req, res) {
  5.   // we have to wrap our *await* commands in
  6.   // an async function for them to work
  7.   (async () => {
  8.     // Generate the PDF
  9.     .
  10.     .
  11.     .
  12.     await page.pdf(PDFOptions)
  13.  
  14.     // Upload to t
  15.     dbx.filesUpload({ path: dbxPath, contents, mode: 'overwrite' })
  16.       .then(response => {
  17.         // NEW RETURN when promise resolves (is that what's happening?)
  18.         // Send Dropbox response back with status
  19.         return res.status(200).send(response)
  20.       })
  21.       .catch( err => res.sendStatus(500) )
  22.  
  23.   })()
  24.  
  25.   // "Always return Status 200/ok"
  26.   // DEPRECATED
  27.   // res.sendStatus(200)
  28.  
  29. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top