A
A
Alexander Savchuk2015-06-07 21:39:26
JavaScript
Alexander Savchuk, 2015-06-07 21:39:26

How to make a request from Angular to VK API?

Good afternoon!

Interested in the following question. How to make a request to the VK API using the $http service. Here's how I do it:

$http.jsonp(VkontakteUtils.buildVKMethodUrl('groups.getById'), {
    method: 'GET'
})


In response I get:
Uncaught SyntaxError: Unexpected token :                   groups.getById?group_id=python_programing:formatted:1


In the Network tab (Google Chrome) I see that the data is received correctly, but it seems that there is a problem with parsing. Help me please.

Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Savchuk, 2015-06-07
@MrLinch

The solution was found. If anyone needs:

$http.jsonp(VkontakteUtils.buildVKMethodUrl('groups.getById'), {
    method: 'GET',
    params: {
        callback: 'JSON_CALLBACK'    
    }
})

V
vinnyzepooh, 2015-08-31
@vinnyzepooh

Good afternoon.
Can you tell me how you signed up? I want to make a similar request, from a separate site that will not be embedded in the iFrame VK. Is it suitable for such purposes:
VK.init({
apiId: id
});
?
Or should another method be used?
Sorry if the question is a bit off topic.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question