Created
December 6, 2021 23:18
-
-
Save ShariqT/30fd3fa58a41a4b7c1cc4ab333a26f77 to your computer and use it in GitHub Desktop.
postcard-list.js
This file contains 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
import L from "lob"; | |
export default async function listPostcards(req, res) { | |
const Lob = L(process.env.LOB_SECRET_API_KEY); | |
Lob.postcards.list( | |
{ | |
limit: 50, | |
}, | |
function (err, data) { | |
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, postcards: data.data, count: data.count }) | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment