Storing the tagged users and displaying them in the user's feed

Along with the text and files, we now send a list of user IDs—users that should be tagged in the post. As mentioned before, they come to the server in the form of a string. We need to use JSON.parse to convert them into a regular array. The following lines are part of the backend/api/content.js module:

var form = new formidable.IncomingForm();
form.multiples = true;
form.parse(req, function(err, formData, files) {
  var data = {
    text: formData.text
  };
  if(formData.pageId) {
    data.pageId = formData.pageId;
  }
  if(formData.eventDate) {
    data.eventDate = formData.eventDate;
  }
  if(formData.taggedFriends) {
    data.taggedFriends = JSON.parse(formData.taggedFriends);
  }
  ...

The content.js module is the ...

Get Node.js By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.