JSFiddle - React, Tailwind, and code Playground

by Sergei Sokolov

JavaScript

/**
 * для вопроса https://toster.ru/q/416501
 */
function getPhoto( id, callback) {
	$.post({
			url: "https://api.vk.com/method/users.get",
			data: {
				 user_id: parseInt(id),
				 fields: "photo_100",
				 v: 5.63
			},
			dataType: "jsonp",
			success: function(r) {
			  if(r && r.response && r.response[0].photo_100) {
				  return callback(r.response[0].photo_100);
				} else {
				  console.log("No photo in response")
				}
			}
	});
}

function gotPhoto( url) {
  var img = $('<img>')
		.attr('width', 100)
		.attr('height', 100)
		.attr('src', url)
	;
	$('body').append(img);
	
}

getPhoto( 755074, gotPhoto);