http://plnkr.co/edit/jpa7xRkmCOJfFbia79ar?p=preview
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script src="http://vk.com/js/api/openapi.js"></script>
<div class="container" id='container'>
<h1 id="headerInfo"></h1>
</div>
<script src="script.js"></script>
</body>
</html>
window.addEventListener('load', () => {
VK.init({
apiId: 5580872
});
VK.Auth.login(function(response){
if(response.session){
VK.api('users.get', {'name_case': 'gen', 'fields': 'photo_200_orig'}, response => {
if(response.error){
alert(response.error.error_msg);
}
else{
console.log(response)
let userData = response.response[0];
console.log(userData.photo_200_orig);
var ava = userData.photo_200_orig
headerInfo.textContent = `Аватарка со страницы ${userData.first_name} ${userData.last_name}`;
var img = document.createElement('img')
img.src=ava;
container.appendChild(img)
}
});
}
else{
alert('Не удалось авторизироваться')
}
}, 8);
})