I'm using pnpjs v 2.0.0 with SPFX to achieve some list operations.
public async getitem(listname) {
// get a specific item by id
const item: any = await sp.web.lists.getByTitle(listname).items.getById(20).get();
console.log(item);
// await item.like();
// get the liked by data
const likedByData: ILikeData[] = await item.getLikedBy();
console.log(likedByData);
// get the liked by information
const likedByInfo: ILikedByInformation = await item.getLikedByInformation();
console.log(likedByInfo);
}
I get the item object but can't add a like to it, I'm getting the error :
Uncaught (in promise) TypeError: item.like is not a function
I've used the docummentation : @pnp/sp/comments and likes