Skip to content

Commit

Permalink
Merge pull request #5 from Deri-Kurniawan/production
Browse files Browse the repository at this point in the history
renaming variables
  • Loading branch information
Deri-Kurniawan authored Oct 1, 2021
2 parents 59f3970 + 53f46d5 commit 1c93b2a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ const getAllBook = (request, h) => {
name = null,
} = request.query;

let allBooks = [];
let allBook = [];

if (reading === null && finished === null && name === null) {
allBooks = books;
allBook = books;
return successResponse(h, 200, {
"status": "success",
"data": {
"books": allBooks.map(({
"books": allBook.map(({
id,
name,
publisher,
Expand All @@ -90,17 +90,17 @@ const getAllBook = (request, h) => {
}
});
} else if (reading !== null) {
allBooks = books.filter((book) => Number(reading) === Number(book.reading));
allBook = books.filter((book) => Number(reading) === Number(book.reading));
} else if (finished !== null) {
allBooks = books.filter((book) => Number(finished) === Number(book.finished));
allBook = books.filter((book) => Number(finished) === Number(book.finished));
} else if (name !== null) {
allBooks = books.filter((book) => book.name.toLowerCase().includes(name.toLowerCase()));
allBook = books.filter((book) => book.name.toLowerCase().includes(name.toLowerCase()));
}

return successResponse(h, 200, {
"status": "success",
"data": {
"books": allBooks.map(({
"books": allBook.map(({
id,
name,
publisher,
Expand Down

0 comments on commit 1c93b2a

Please sign in to comment.