Answer the question
In order to leave comments, you need to log in
How to fix an error in VK api?
I decided to create a site for sending messages to VK conversations, but the same error appears in the console:
Failed to load https://api.vk.com/method/messages.send : No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
Everything works, but the error remains anyway, how to remove it? The solution is desirable with an explanation, I'm a beginner)
var message,
token,
count,
interval,
begin,
link;
func(){
$.post('https://api.vk.com/method/messages.send', {
access_token: token,
v: '5.80',
peer_id: 2000000000 + begin,
message: message,
attachment: link
}, console.log),
begin++
};
var timerId = setInterval(func, interval);
setTimeout(function(){
clearInterval(timerId);
}, interval * count);
Answer the question
In order to leave comments, you need to log in
https://github.com/github/fetch/issues/301
If you do not know English, then in short: the server must confirm the availability by sending a response with the Access-Control-Allow-Origin header. If you are testing on localhost, then it is easier to fix it by installing a chrome extension (the link is in the discussion on github).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question