Hi,
I am trying to get the SourceID of the document in Async call using await keyword but i am not getting the value.
I am new to this concept, could anyone tell where i am doing mistake. I have added my code in below code snippet
public async GetListItems(ListTitle: string): Promise<any[]> { debugger; let ListCardItemsArray: ListCardListItem[] = []; let ListCardListItm: ListCardListItem = null; return new Promise<any[]>(async (resolve, reject) => { await sp.web.lists.getByTitle(ListTitle).items.select("*").get().then((results: any) => { results.map((result: any) => { let sourceID: string; ListCardListItm = new ListCardListItem(); ListCardListItm["Title"] = result.Title; ListCardListItm["Description"] = result.Description; ListCardListItm["DocumentURL"] = result.DocumentURL; //here i am calling my method let sourceID = this.GetSourceID(""); ListCardListItm["SourceID"] = ""; ListCardListItm["VisioURL"] = result.VisioURL; ListCardItemsArray.push(ListCardListItm); }) console.log(ListCardItemsArray); resolve(ListCardItemsArray); }, (error: any) => { console.log("Error of GetListItems " + error); resolve(error); }); }); } public async GetSourceID(LinkURL: string) { let sourceID: string = ""; try { let result = await sp.web.getFileByUrl("https://contosa.sharepoint.com/:u:/r/sites/Sample/SampleLibrary/Sample.vsdx?d=we836259ffe4b4f6c96ca6dd1118e6629&csf=1&web=1&e=B2w69d").select("*").get(); sourceID = await result.UniqueId; console.log(sourceID); return sourceID; } catch (error) { console.log(error); } }