Guest User

Untitled

a guest
Dec 11th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  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. })
Add Comment
Please, Sign In to add comment