Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. componentDidMount() {
  2. const select = ['ServerRelativeUrl', 'Title'];
  3. this.sp.getSubwebsFilteredForCurrentUser()
  4. .select(...select)
  5. .get()
  6. .then(projects => {
  7.  
  8. const getProject = (project) => {
  9. const transformItems = (items) =>
  10. items.map( (item) =>
  11. {
  12. "Title" : project.Title,
  13. "Informations" : item
  14. });
  15. const endOfThePage = project.ServerRelativeUrl.split('/')[2];
  16. const projectPage = new pnp.Web(`XXX`);
  17.  
  18. return projectPage.lists.getByTitle('Strony witryny')
  19. .items
  20. .select('BannerImageUrl', 'Description', 'Czy_x0020_promowany_x003F_', 'Czy_x0020_prywatny_x003F_', 'Tagi', 'Zrealizowany')
  21. .filter("Title eq 'Strona główna'")
  22. .filter("Czy_x0020_prywatny_x003F_ eq 'False'")
  23. .getAll()
  24. .then(transformItems);
  25. };
  26.  
  27. const promises = projects.map(getProject);
  28. return Promise.all(promises);
  29. })
  30. .then( configuredProjects => {
  31. //console.log('Then configured projects', configuredProjects);
  32. //this.setState({...this.state, projects: configuredProjects});
  33. })
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement