Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ./routes/api/index.js
- // the router is already using /api (see routes/index.js), so this is actually a post to /api/
- router.post('/', function(req, res) {
- // we have to wrap our *await* commands in
- // an async function for them to work
- (async () => {
- // Generate the PDF
- .
- .
- .
- await page.pdf(PDFOptions)
- // Upload to t
- dbx.filesUpload({ path: dbxPath, contents, mode: 'overwrite' })
- .then(response => {
- // NEW RETURN when promise resolves (is that what's happening?)
- // Send Dropbox response back with status
- return res.status(200).send(response)
- })
- .catch( err => res.sendStatus(500) )
- })()
- // "Always return Status 200/ok"
- // DEPRECATED
- // res.sendStatus(200)
- })
Add Comment
Please, Sign In to add comment