Domanda

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.

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top