The error handling for async/await with try/catch always bugs me. Go to the rescue?
function to(promise) {
return promise
.then(res => [null, data])
.catch(err => [err])
}
async function doIt() {
const [err, data] = await to(request("https://jsonplaceholder.typicode.com/posts"))
if (err) return console.error("Dat error though...")
return data
}