May 29 2020 11:13 AM
I need to test to see if an image exists in a library. I am basing my code on the PNP JS documentation found here: https://pnp.github.io/pnpjs/sp/files/
This code works
const file = sp.web.getFileByUrl(url);
but it always returns an object. My challenge had been, how to tell if the object is indicating the image exists or doesn't. The only thing that has worked for me is to call the getItem() then fieldValuesAsText().
sp.web.getFileByUrl("").getItem().then(function(val){
val.fieldValuesAsText()
});
May 30 2020 10:20 PM