0

Can anyone guide me to how to get document from Sharepoint Library using rest api in Spfx ,tried using below code to bind static data in Detailed List ,but unable to get rest api call ?

                        function _generateDocuments() {
                          const items: IDocument[] = [];
                          
                          for (let i = 0; i < 500; i++) {
                            const randomDate = _randomDate(new Date(2012, 0, 1), new Date());
                            const randomFileSize = _randomFileSize();
                            const randomFileType = _randomFileIcon();
                            let fileName = _lorem(2);
                            fileName = fileName.charAt(0).toUpperCase() + fileName.slice(1).concat(`.${randomFileType.docType}`);
                            let userName = _lorem(2);
                            userName = userName
                              .split(' ')
                              .map((name: string) => name.charAt(0).toUpperCase() + name.slice(1))
                              .join(' ');
                            items.push({
                              key: i.toString(),
                              name: fileName,
                              value: fileName,
                              iconName: randomFileType.url,
                              fileType: randomFileType.docType,
                              modifiedBy: userName,
                              dateModified: randomDate.dateFormatted,
                              dateModifiedValue: randomDate.value,
                              fileSize: randomFileSize.value,
                              fileSizeRaw: randomFileSize.rawSize,
                            });
                          }
                          return items;
                        } 

Thought of using jquery ajax call to get items using below code but how to push items from resultData.d.results in Detailed list

                     var reactHandler = this;    
                        jquery.ajax({    
                            url: `${this.props.siteurl}/_api/web/lists/getbytitle('EmployeeList')/items`,    
                            type: "GET",    
                            headers:{'Accept': 'application/json; odata=verbose;'},    
                            success: function(resultData) {             
                              reactHandler.setState({    
                                items: resultData.d.results    
                              });    
                            },    
                            error : function(jqXHR, textStatus, errorThrown) {    
                            }    
                        });    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.