you can use JSOM to like an Item
var setLike = function (context, listId, itemId, isLike, likescount) {
SP.SOD.executeFunc('reputation.js', 'Microsoft.Office.Server.ReputationModel.Reputation', function () {
Microsoft.Office.Server.ReputationModel.Reputation.setLike(context, listId, itemId, isLike);
context.executeQueryAsync(function () {
}, function (sender, args) { console.error(args.get_message()) });
});
return false;
};
isLike is a boolean value, you can get to know whether to like or unlike by
var getisLiked = function (likedby) {
var isliked = false;
if (likedby !== null && likedby !== undefined) {
for (var i = 0; i < likedby.length; i++) {
var like = likedby[i];
if (like.get_lookupId() === _spPageContextInfo.userId) {
isliked = true;
break;
}
}
}
return isliked;
};
likedBy is the Value of "LikedBy" column (internal name)