Не добавляется пост в бд

На клиенте отправляю фото на сервер:

function submitForm(e) {
    e.preventDefault();

    const res = {
      id: window.location.pathname.replace(/\/profile\//, ''),
      images: images_of_post
    };

    socket.emit('photos', JSON.stringify(res));
 }

На сервере получаю текст и массив фото к посту, создаю новый пост с информацией и сохраняю в бд:

APP.post('/profile/:id', (req, res) => {
  try {
    io.on('connection', socket => {
      socket.on('photos', async(images) => {
        const { text } = req.body;
        const findUser = await User.findById(req.params.id);

        const newPost = new Post({
          userId: findUser._id,
          user: findUser,
          text,
          photos: images,
          date: new Date(),
          comments: []
        })

        await newPost.save();
      });
    });
  } catch (e) {
    res.status(404).json({ message: e.message });
  }
})

Но в бд нет нового поста, что не так?


Ответы (0 шт):