Answer the question
In order to leave comments, you need to log in
`
Why does VK API return code 200 and undefined?
let connection = new XMLHttpRequest();
connection.open('GET', `${ prefix }groups.getLongPollServer?group_id=202228658${ postfix }`);
connection.responseType = 'json';
connection.send();
const connection_timer = setTimeout(() => {
console.log('ERROR! Shit happened! Server connection timeout!');
}, 5000)
connection.onload = () => {
clearTimeout(connection_timer);
console.log(connection.status);
console.log(connection.response);
}
connection.onerror = () => {
console.log('ERROR! Shit happened! Bad server connection!');
}
Answer the question
In order to leave comments, you need to log in
Problem solved.
1) Instead of connection.response, you should have used connection.responseText
2) After that, error 15 was returned, but this is my oversight - to receive longpoll server vk data, you need to create an access key with the right to manage the community
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question