# Getting blank when i try to get Site contents list

**URL:** <https://techcommunity.softwareag.com/t/getting-blank-when-i-try-to-get-site-contents-list/281006>\
**Category:** Forum\
**Tags:** SPFX\
**Created:** [July 13, 2023, 2:50pm UTC](https://techcommunity.softwareag.com/t/getting-blank-when-i-try-to-get-site-contents-list/281006 "2023-07-13T14:50:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kmurali\_krishna](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/kmurali_krishna/32/28646_2.png) [@kmurali\_krishna](https://techcommunity.softwareag.com/u/kmurali_krishna)\
**Post date:** [July 13, 2023, 2:50pm UTC](https://techcommunity.softwareag.com/t/getting-blank-when-i-try-to-get-site-contents-list/281006/1 "2023-07-13T14:50:55Z")

</div>

Hi Team,  
I have followed a YouTube channel to get SP list items, which is working fine, in the same way I have tried to get SP site contents list (Get SP lists) which is return blank values.

```auto
WebPart Render Function 

public render(): void {
    const element: React.ReactElement<IGetSpListsProps> = React.createElement(
      GetSpLists,
      {
        description: this.properties.description,
        websiteUrl: this.context.pageContext.web.absoluteUrl
      }
    );

    ReactDom.render(element, this.domElement);
  }

Component Interface file
export interface IGetSpListsProps {
  description: string;
  websiteUrl: string;
  
}

Component TSX file
export interface IGetSpListsState{
  sitecontents: [{"Lists":""}]
}

export default class GetSpLists extends React.Component<IGetSpListsProps, IGetSpListsState> {
    static siteurl:string =""; //static member variable
    public constructor (props :IGetSpListsProps, state:IGetSpListsState ){
     super(props);
     this.state={sitecontents: [{"Lists":""}]};
      GetSpLists.siteurl=this.props.websiteUrl;
    }
    
    public componentDidMount() {
      let reactcontexthandiler= this;
      jquery.ajax({
        url: `${GetSpLists.siteurl}/_api/web/lists?select=Title&$filter=Hidden eq true`,
        type:"GET",
         headers:{'Accept': 'application/json;odata=verbose;'},
         success : function (resultData){
          reactcontexthandiler.setState({sitecontents: resultData.d.results});
         },
         error: function (jqXHR, textStatus, errorthrown){
          }
        });
    }
    
    public render(): React.ReactElement<IGetSpListsProps> {
      return (
      <div>
        <ol>
        {
          this.state.sitecontents.map(function(mylists,mylistitemkey){
            return(
              <li>
              <span>{mylists.Lists}</span>
              </li>);
              })
        }
      </ol>
      </div>
      
    );
  }
}

```

Please find the screen shot below what the output the above code gets

 ![emptylistscreenshot](https://global.discourse-cdn.com/techcommunity/original/3X/4/5/451ff023278e4b06a684f614144b724b860f9e0a.png)

Any assistance please?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [January 9, 2024, 2:51pm UTC](https://techcommunity.softwareag.com/t/getting-blank-when-i-try-to-get-site-contents-list/281006/2 "2024-01-09T14:51:31Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
