Conditional Return With Flat Map

Mar 14, 2021

Javascript

work-in-progress

const posts = idList.flatMap((slug: string) => {
  const post = getPostBySlug(slug, fields);
  return post ? [post] : [];
});