How To See Who Liked The SharePoint Modern Site Page

The Modern SharePoint site pages have a lot of hidden features. One of them is the “Like this page” social feature. This feature enables the option to like the modern site page. In this post, we’ll see how to get the total likes and see who has liked the page of the modern SharePoint site page.
The below SharePoint Rest API is used to retrieve the liked Information of the page item.
 
Format of the Request URL:
 
https://domain.sharepoint.com/sites/name/_api/web/lists/getbyTitle('<Library Name>')/GetItemById(<Page List Item ID>)/likedByInformation?$expand=likedby&$select=likedby
 
To test this, open the browser console and paste the below code and make the changes to the site URL, library name and Item ID:
  1. //getRequest method reference    
  2. //https://gist.github.com/ktskumar/a9e9df497673e9fd26ead8532b9ff425    
  3. function getRequest(url) {    
  4.     var request = new XMLHttpRequest();    
  5.     return new Promise(function(resolve, reject) {    
  6.         request.onreadystatechange = function() {    
  7.             if (request.readyState !== 4) return;    
  8.             if (request.status >= 200 && request.status < 300) {    
  9.                 resolve(request);    
  10.             } else {    
  11.                 reject({    
  12.                     status: request.status,    
  13.                     statusText: request.statusText    
  14.                 });    
  15.             }    
  16.         };    
  17.     
  18.         request.open('GET', url, true);    
  19.         request.setRequestHeader("Content-Type""application/json;charset=utf-8");    
  20.         request.setRequestHeader("ACCEPT""application/json; odata.metadata=minimal");           
  21.         request.setRequestHeader("ODATA-VERSION""4.0");    
  22.         request.send();    
  23.     
  24.     });    
  25. }    
  26.     
  27. //Returns the user names liked the page. Page is identified based on the Id    
  28. //Also returns the User ID, Email, Liked Time, ...    
  29. getRequest("https://domain.sharepoint.com/sites/name/_api/web/lists/getbyTitle('Site Pages')/GetItemById(1)/likedByInformation?$expand=likedby&$select=likedby").then(function(output) {    
  30.     var result = JSON.parse(output.response);    
  31.     var strMessage = "Total Likes: " + result.likeCount + "\r\n";    
  32.     for (var i = 0; i < result.likedBy.length; i++) {    
  33.         strMessage += result.likedBy[i].name + "\r\n";    
  34.     }    
  35.     alert(strMessage);    
  36. });