Closed gargankush010 closed 5 years ago
i got it. For my fellow newbie SPFx developers, i am posting my solution. Just replace the followedsites() method with this.
private followedSites(): void{ this.getFollowedSites().then((Response)=>{ var options: Array<favoritesitesurl> = new Array<favoritesitesurl>(); console.log("Response is : ",Response); Response.forEach(element => { console.log(element.ContentUri); }); }); }
Hi Everyone,
I am new to SPFx so please bear with my foolish mistakes. I am trying to make a webpart which gets the current logged in user's 'Following sites' using pnp. I got the URLs of following sites and i can see the returned promise in console as well. I just dont know how should i resolve this Response. Please help. `import { Version } from '@microsoft/sp-core-library'; import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base'; import { IPropertyPaneConfiguration, PropertyPaneTextField } from '@microsoft/sp-property-pane'; import { escape } from '@microsoft/sp-lodash-subset';
import styles from './MyfavoritesWpWebPart.module.scss'; import * as strings from 'MyfavoritesWpWebPartStrings'; import { sp, SocialActorTypes } from "@pnp/sp";
export interface IMyfavoritesWpWebPartProps { description: string; allfavoritessitesurl: favoritesitesurl[]; } export interface favoritesitesurl { ContentUri: string; } export default class MyfavoritesWpWebPart extends BaseClientSideWebPart {
public render(): void {
}
private followedSites(): void{ this.getFollowedSites().then((Response)=>{ var options: Array = new Array();
console.log("Response is : ",Response);
Response.value.map(()=> {
options.push({ContentUri: Response.ContentUri});
});
}
public async getFollowedSites() :Promise {
const uri = await sp.social.my.followed(SocialActorTypes.Site);
console.log(uri);
return uri;
}
protected get dataVersion(): Version { return Version.parse('1.0'); }
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration { return { pages: [ { header: { description: strings.PropertyPaneDescription }, groups: [ { groupName: strings.BasicGroupName, groupFields: [ PropertyPaneTextField('description', { label: strings.DescriptionFieldLabel }) ] } ] } ] }; } } `