Skip to content

Instantly share code, notes, and snippets.

@ShariqT
Created November 19, 2021 05:12
Show Gist options
  • Save ShariqT/309cb027468c031bd9aab5fe8f43d632 to your computer and use it in GitHub Desktop.
Save ShariqT/309cb027468c031bd9aab5fe8f43d632 to your computer and use it in GitHub Desktop.
create.js
const { toAddress, fromAddress, frontTemplate, backTemplate, description } = req.body;
Lob.postcards.create(
{
description: description,
to: toAddress,
from: fromAddress,
front: frontTemplate,
back: backTemplate,
},
function (err, postcard) {
if (err) {
return res.status(err.status_code || 500).send({
success: false,
error_message:
err?._response?.body?.error?.message ||
err.message ||
"Unknown error.",
});
} else {
res.send({ success: true, postcard: postcard});
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment