INNER CODE UNIT · JavaScript

appendData

eknoorpreet/dev.to-clone · client/src/utils/index.js:24

export const appendData = (data) => {
  const formData = new FormData();
  for (let [key, value] of Object.entries(data)) {
    if (Array.isArray(value)) {
      value = JSON.stringify(value);
    }
    formData.append(`${key}`, value);
  }
  return formData;
};

export const getReplies = (comments, commentId) => {
  return (
    comments &&
    comments
      .filter((comment) => comment && comment.parentId === commentId)
      .sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime())
  );

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…