Last active
July 2, 2018 08:11
-
-
Save puemos/7031951bc75a7341187a213b4f85b592 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
async function publishAll() { | |
// You get the posts | |
const posts = await getPosts(); | |
const successes = []; | |
const failures = []; | |
for (const post of posts) { | |
// synchronous check for validtion | |
if (!validate(post)) { | |
failures.push({ post, status: "failed" }); | |
} else { | |
// publish it to the 3rd party api | |
try { | |
await publish(post); | |
results.push({ post, status: "published" }); | |
} catch (e) { | |
failures.push({ post, status: "failed", error: e }); | |
} | |
} | |
} | |
return { | |
successes, | |
failures | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment