L
L
lemonlimelike2019-04-09 03:00:30
JavaScript
lemonlimelike, 2019-04-09 03:00:30

How to get information about the VK API group?

Hello! Who will tell me why I can not get information about the group? It seems that I set access-control-allow-origin in headers, but the code still does not work.

axios.get('https://api.vk.com/method/users.get',{
  params:{
    user_id:210700286,
    v:5.52
  },
  headers:{
    'Content-Type':'application/json',
    'Access-Control-Allow-Origin':'*'
  }
})
.then((response) =>{
  console.log(response)
})
.catch((error) =>{
  console.log(error)
})

5cabe09d1bca9954826678.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
irishmann, 2019-04-09
@lemonlimelike

The browser adds its origin header. As far as I understand Access-Control-Allow-Origin, JS solves little, so I used CORS Proxy.

$.ajax({
  type:'POST',
  url: 'https://cors-anywhere.herokuapp.com/http://aiproject.ru/api/',
  'data': { 
    query: '{"ask":"'+message+'","userid":'+id+',"key":"1"}'
  },
  'success': function(data){
    msg = JSON.parse(data);
    $(".messages").append('<li><div class="text-msg receive_msg">'+msg['aiml']+'</div></li>');
    while($(".messages li").length > 7){
      $('li:first').detach();
    }
  }
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question