Answer the question
In order to leave comments, you need to log in
User selection in JSON?
Guys, tell me, please, how to make a user choice in JSON. I need to select a user from an array, but the problem is that the user is in multiple conversations. How to make user selection of a specific conversation?
Answer the question
In order to leave comments, you need to log in
you need to have a conversation base and an array with users in it, then you need to find the conversation base by its id and then also find the user from the array.
I will make an example:
const base = [
{
"chatId": 1,
"users": [
{
"id": 123
}
]
}
]; // типа JSON-база
// представим, что объект сообщения ВК называется message
const peer = base.filter(x => x.chatId === message.chatId)[0];
const user = peer.users.filter(x => x.id === message.senderId)[0];
console.log(user);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question