W
W
Web Lizard2016-01-04 02:29:05
JavaScript
Web Lizard, 2016-01-04 02:29:05

Why doesn't Open API initialization work?

I'm trying to initialize the API like this:

VK.init({
    apiId: 5213033
});

Error in console:
Uncaught TypeError: Cannot read property 'insertBefore' of undefined

What am I doing wrong? Such an ID definitely exists, I copied it from VKontakte

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vasily Bodnaryuk, 2018-08-12
@Vasilesk

It's simple: you have this code executed before the body tag is loaded , but should be executed after . For some reason, this was not taken into account in the documentation. So, change your code snippet to something like this

document.addEventListener("DOMContentLoaded", function () {
    VK.init({
        apiId: 5213033
    });
});

I
Ivan Kondratiev, 2016-01-04
@inik23

Somehow a very small key for api. But the error is strange. In which file does it appear. Drop the code.

N
nukantri, 2016-01-16
@nukantri

regardless of the application number - I have the following in the console:
at the same time - INITIALIZATION works fine, I think the "error" of the vk developers is not critical, and your code has nothing to do with the alarm in the console,
maybe you meant AUTHORIZATION?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question