2
const query =  `<Where>
    <Eq><FieldRef Name="File_x0020_Type"/>      
        <Value Type="Text">json</Value> 
    </Eq> 
</Where>`;
const xml = '<View Scope="RecursiveAll"><Query>' + query + '</Query></View>';  
const result = sp.web.lists.getByTitle('myassets').getItemsByCAMLQuery({'ViewXml':xml}).then((res:any).then((res:any) => { return res; })

Used the CAML query above to fetch files, but I can't get the json content of the files. I looked at the json returned and I don't see anything relating to the content of the files. Is there a way to get the content of several files fetched through CAML? I know there's a PnP method to fetch an individual json, but I need to get the json of every file fetched at once.

3

Sample demo:

const query =  `<Where>
        <Eq><FieldRef Name="File_x0020_Type"/>      
            <Value Type="Text">json</Value> 
        </Eq> 
    </Where>`;
    const xml = '<View Scope="RecursiveAll"><Query>' + query + '</Query></View>';  
    sp.web.lists.getByTitle('MyDoc2').getItemsByCAMLQuery({'ViewXml':xml},'FileRef').then((items:any) => {
      items.map((item)=>{
        console.log(item);
        sp.web.getFileByServerRelativeUrl(item.FileRef).getJSON().then((data)=>{
          console.log(data);
        })
      }) 
    })

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.