Skip to content
This repository has been archived by the owner on Jul 21, 2022. It is now read-only.

Commit

Permalink
fix: use 'find' instead of 'filter'
Browse files Browse the repository at this point in the history
  • Loading branch information
awgaan committed Aug 19, 2021
1 parent ce666f2 commit 11c59fd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions amplify/backend/function/createUserformBatch/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,18 @@ async function mapQuestionAnswers(newAnswers, oldAnswers, useNewUserform) {
return newAns;
}

const old = oldAnswers.filter(
const old = oldAnswers.find(
(oldAns) => oldAns.questionID === newAns.questionID
);
// console.log("old question: ", old);
if (old.length > 0) {
if (old) {
//If using new userform, all answers need to be create
if (useNewUserform) {
newAns.action = Action.Create;
} else {
//Makes it possible to bypass the timeLimit variable (gotten from database (in future)), mostly used for testing
if (useTimeLimit) {
newAns.questionAnswerId = old[0].id;
newAns.questionAnswerId = old.id;
newAns.action = Action.Update;
newAns.updatedAt = new Date(millisecToday).toISOString();
} else {
Expand Down

0 comments on commit 11c59fd

Please sign in to comment.