I created an application on vk.com/dev . In the settings indicated the site address http://localhost:8081/ , Basic domain: localhost . Then I connected the vkapi library and try to log in:

 var vk = new VK({ 'appID' : 5624111, 'appSecret' : 'BSXVqQsTSO66GDEF1111', 'mode' : 'oauth' }); 

But in the console error:

Uncaught Error: nodejs-vk-sdk: you have to specify VK application id

ID and key are exactly correct. What did I forget to add?

    1 answer 1

    Problem in writing the word appID , change appID to appId

    This should solve your problem.

    You should also check the relevance of the library version by checking the library page on GitHub

    Here is the working code:

     var VK = require('vksdk'); var vk = new VK({ 'appId' : 2807970, 'appSecret' : 'L1ZKpgQPalJdumI6vFK', 'mode' : 'sig' }); 

    Check in browser

    • I try to get a request and get an error https://api.vk.com/method/users.get. No 'Access-Control-Allow-Origin' header is present on the requested resource. ... https://api.vk.com/method/users.get. No 'Access-Control-Allow-Origin' header is present on the requested resource. ... https://api.vk.com/method/users.get. No 'Access-Control-Allow-Origin' header is present on the requested resource. ... try through localhost, I also specified localhost in the application settings. The problem is that you need to have a server for such requests? - Slava
    • @Slava, localhost does not point to your computer; in the application settings, specify the address of your computer from which the API request is made. - Aim X