Практическая работа №4#4
Conversation
|
|
||
| async getAll() { | ||
| try { | ||
| const response = await window.fetch(URL.RECIPES); |
There was a problem hiding this comment.
просто используй fetch вместо window.fetch.
|
|
||
| handleShowAll(e) { | ||
| e.preventDefault(); | ||
| while (this.recipeList.lastChild) { |
| this.emit(EVENTS.DELETE, { id }); | ||
| } | ||
|
|
||
| addRecipe({ name, _id, ingredients: ingr, instruction: instr, favorite }) { |
There was a problem hiding this comment.
слишком большой метод, надо было разнести на мелкии.
| @@ -0,0 +1,6 @@ | |||
| import 'dotenv/config'; | |||
|
|
|||
| export const { PORT } = process.env; | |||
There was a problem hiding this comment.
зачем экспорт каждого по отдельности?
export const { PORT, DATABASE_URL, DB_USER , DB_PASSWORD } = process.env;
|
|
||
| // прокидываем models в request\response цикл | ||
|
|
||
| app.use(async (req, res, next) => { |
| // прокидываем models в request\response цикл | ||
|
|
||
| app.use(async (req, res, next) => { | ||
| req.context = { |
There was a problem hiding this comment.
req.context не вижу профита в этом, почему не импортировать модели в нужное место, чем к каждому запросу их прокидывать, там где они даже могут быть и не нужны.
| this.recipeList.removeChild(card.parentNode); | ||
| } | ||
|
|
||
| addToFavorites(card, id, img) { |
There was a problem hiding this comment.
можно было бы вынести в метод и воспользоваться как для addToFavorites так и для delFromFavorites
| handleCreateRecipe(e) { | ||
| e.preventDefault(); | ||
| const d = document; | ||
| const name = d.getElementById('name').value; |
|
|
||
| showEditRecipeModal({ target }) { | ||
| const d = document; | ||
| const card = target.parentNode.parentNode; |
There was a problem hiding this comment.
много где повторяется target.parentNode.parentNode, можно было написать утил функцию которая рекурсивно достаёт и передавал параметр как далеко опускаться в рекурсии.
No description provided.