M
M
mrsakura522021-11-11 21:41:09
In contact with
mrsakura52, 2021-11-11 21:41:09

How to send an object to node.js?

I send a message using vk.api.messages.send(). It is sent, but I also pass in the message findOne mongo method.

vk.api.messages.send({
    random_id: dateUTC,
    peer_id: config.admins,
    message: '[BOT] Пожалуйста, проверьте наличие оплаты у пользователя ' + message.senderId + '\n\nСпособ оплаты: ' + screen[1] + '\n' + String(spokes.findOne({userID: message.senderId})) + '\nИспользуйте команду /screen <Пользователь> <true/false>'
                })


The json object from the database is displayed in the console, and the message is sent at this place [object Promise]. How to send this json object there from the database?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
ork821, 2021-11-12
@mrsakura52

1) it may be worth putting await, since any request to the database is asynchronous.
2) You can only send an object over the network by making it a string (or a set of bytes), like this: JSON.stringify(object)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question