Skip to content

Instantly share code, notes, and snippets.

@ranyefet
Created September 16, 2015 09:15
Show Gist options
  • Save ranyefet/230eb3ace0d7e7813a88 to your computer and use it in GitHub Desktop.
Save ranyefet/230eb3ace0d7e7813a88 to your computer and use it in GitHub Desktop.
var posts = response.posts.map(post => {
var reason = post.reason_title ? {
type: post.reason_title.reason_enum,
user: {
id: post.reason_title.user.user_id,
name: post.reason_title.user.name,
}
} : null;
var follow_up_to = post.mobile_follow_up_to ? {
id: post.mobile_follow_up_to.post_id,
question: post.mobile_follow_up_to.q_text,
} : null;
return {
id: post._id,
question: post.q_text,
answer: post.a_simple_text,
allow_comments: post.allow_comments,
asked_at: post.created_at,
asked_by: {
id: post.creator_id,
name: post.creator_name,
photo: post.creator_pic_url,
},
answered_at: post.answered_at,
answered_by: {
id: post.user_id,
name: post.user_name,
photo: post.user_pic_url,
},
photos: post.photos,
liked: post.liked,
stats: {
comments: post.num_comments,
likes: post.num_likes,
views: post.num_views,
},
reason,
follow_up_to,
tags: post.tags,
updated_at: post.updated_at,
permalink: post.full_link,
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment