Skip to content

Diana Garbuzova (i'm so tired)#4

Open
MelodyWithAttitude wants to merge 4 commits intosanmaal:masterfrom
MelodyWithAttitude:master
Open

Diana Garbuzova (i'm so tired)#4
MelodyWithAttitude wants to merge 4 commits intosanmaal:masterfrom
MelodyWithAttitude:master

Conversation

@MelodyWithAttitude
Copy link
Copy Markdown

No description provided.

Comment thread diana_garbuova/.env
@@ -0,0 +1,7 @@
APP_PORT=3000
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

спасибо за твои учетные данные ) но на будующее добавь .env в гитигнор


router.post('/:pokename', checkToken, async (req, res) => {
await Pokemon.findOne({ name: req.params.pokename }, (err, pokemon) => {
if (pokemon) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а зачем тут и await и колбек

await Pokemon.findOne({ name: req.params.pokename }, (err, pokemon) => {
if (pokemon) {
User.findByIdAndUpdate(
req.userId,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и ещё промис внутри всего этого


router.get('/', async(req, res) => {
const users = await User.find({}, 'username').exec();
res.status(200).send(users);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а если ошибка? какого-то глобального хэндлинга я не увидел, так что упало тут - упал сервер

Comment thread diana_garbuova/initMongoBoy.js Outdated
})
.then(() => {
Pokemon.collection.insertMany(pokemons)
console.log('Yami!')
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insertMany вроде не синхронно работает, так что Yami несколько преждевременно

Comment thread diana_garbuova/initMongoBoy.js Outdated
Pokemon.collection.insertMany(pokemons)
console.log('Yami!')
})
.catch((e) => console.log(e));
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

оке, соединились, допустим положили в базу что-то, а потом соединение осталось висеть вечность

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants