Forum Discussion
anirudhaditya
May 08, 2022Copper Contributor
SPJS Simple issue
Seems to be a very simple issue but I am not able to crack it. I am using PnPJs 2x version and just doing some demo spfx to understand the CRUD Operations using PnPJs.
So, I have a List called EmployeeDetails and 2 fields there. Just want to create an item. That's it. I am getting the 404 error on the console.
The code snippet
private createItem = async () => {
try {
const addItem = await sp.web.lists.getByTitle("EmployeeDetails").items.add({
'Title': document.getElementById("fullName")['value'],
'Age': document.getElementById("age")['value']
});
console.log(addItem);
alert(`Item created successfully with ID: ${addItem.data.ID}`);
}
catch (e) {
console.error(e);
}
}
By default, the RESTFUL URL is invalid as it adds _layouts/15 which is not needed.
How to get this fixed?
No RepliesBe the first to reply