Tuesday, October 31, 2017

Read SharePoint list Items using REST API and ReactJS

Read SharePoint list Items using REST API and ReactJS

Step1: Create a "ReactDemo" list and list columns as shown below.

Step2: Create an HTML page and saved as "react.html" and upload into Site Assets library in SharePoint. Copy the "react.html" file full url from for future reference. Update below in "react.html" file.

react.html:
<!DOCTYPE html>
<html>
<head>
  <script src="https://unpkg.com/react@15.3.2/dist/react.js"></script>
  <script src="https://unpkg.com/react-dom@15.3.2/dist/react-dom.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>
<style></style>
</head>
<body>
  <div id="container"></div> 
  <script type="text/babel">
    var destination = document.querySelector("#container");
    class LinksClass extends React.Component {
        debugger;
        constructor() {
            super();
            this.state = {
                Links: [
                    {
                        "Link_x0020_Title": "",
                        "Title": ""
                    }
                ]
            };
        }
        componentDidMount() {
            debugger;
            this.RetrieveLinksData();
        }
        RetrieveLinksData() {
            var reactHandler = this;
            var objHeaders = {
                type: "GET",
                headers: {
                    "accept": "application/json;odata=verbose"
                },
                mode: 'cors',
                cache: 'default',
                credentials: 'include'
            }
            fetch("https://sharepointonline01.sharepoint.com/sites/dev/_api/web/lists/getbytitle('ReactDemo')/items",
                objHeaders).then(function (response) {
                return response.json()
            })
            .then(function (json) {
                var results = json.d.results;
                reactHandler.setState({Links: results});    
            })
            .catch(function (ex) {
                console.log('parsing failed', ex)
            })
        }
        render() {
            debugger;
            return (
                <div>
                    <h4>Links</h4>
                    <ul>
                        {this
                            .state
                            .Links
                            .map(function (item, key) {
                                return (
                                    <li key={key}>
                                        <a href={item.Link_x0020_Title.Url}>
                                            {item.Title}
                                        </a>
                                    </li>
                                );
                            })
                          }
                    </ul>
                </div>                  
            );
        }
    }
    ReactDOM.render(
      <LinksClass/>,
      document.getElementById('container')
    );
</script>
</body>
</html>


Step3: Create a webpart page and add content editor webpart in to the page. update content link url with "react.html" page url.

Step4: final result.

20 comments:

  1. Nice Blog!
    I've gone through all the the blog regarding Sharepoint with react to design and develop the great app and I believe that this is the best blog one can learn with. I was looking to hire reactjs development company in India and got your blog.
    Thanks for such a great article.

    ReplyDelete
    Replies
    1. Great Article Cloud Computing Projects

      Networking Projects

      Final Year Projects for CSE

      JavaScript Training in Chennai

      JavaScript Training in Chennai

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      Delete
  2. Good one to begin। With SharePoint and reactjs You may please add other crud operationd in it।

    ReplyDelete
  3. Can you let me know how we can get people or group field value

    ReplyDelete
  4. The article is so appealing. You should read this article before choosing the Big data cloud solutions you want to learn.

    ReplyDelete
  5. How long does a Yorkie live? 13 – 16 years

    Are Yorkies cuddlers?
    A lover of all things comfortable, the Yorkshire terrier enjoys cuddling with loved ones and snuggling into everything soft and fluffy. And for you, their silky coat isn't too bad for petting. https://www.newdaypuppies.com/

    Adorable Teacup and Toy AKC Yorkie Puppies
    We have adorable Yorkshire Terrier puppies male and female (she is pictured with the bow).The little girl was born on and the male was born on. teacup yorkie for sale Both puppies have started potty training and have had all sets of puppy shots and deworming. They both come with AKC papers.The girl is very petite and has an adorable baby doll face. yorkies for sale near me She is a teacup and will mature to be around just lbs. She is very gentle and easy going She is the princess in our home and loves to be held.The male is full of spunk and is super playful He will mature to be lbs and would make an awesome family dog. He has a gorgeous silky coat and adorable teddy bear face.Both puppies are AKC registered and will come with a health guarantee shot record and sample puppy food. https://www.newdaypuppies.com/teacup-yorkie-puppies-for-sale/

    Adorable Teacup and Toy AKC Yorkie Puppies is a Female, Male Yorkshire Terrier Puppy for sale in US. Adorable Teacup and Toy AKC Yorkie Puppies by newdaypuppies for Female, Male Yorkshire Terrier Puppies. yorkie puppies for sale

    ReplyDelete
  6. Is a Yorkie a good family dog?

    Yorkies, like many other Toy breeds, make good pets for people; they're especially good for senior citizens, people with medical issues, and those who may worry about the size and strength of a larger dog. ... They're loving, devoted, and very affectionate: This makes them great personal companions and good family pets.

    Do Yorkshire terriers bark a lot?
    https://www.newdaypuppies.com/teacup-yorkie-puppies-for-sale/
    Yorkshire Terriers are little dogs with huge personalities. teacup yorkies for sale With those huge personalities come a fierce territorial bark. Any time your phone rings, someone speaks or knocks on your door, or your doorbell chimes, your Yorkshire Terrier will likely bark. Outside noises aren't even required for barking for some Yorkies. yorkshire terriers for sale

    How much do Yorkshire terriers cost?
    yorkie for sale near me
    Typical Yorkie prices range from $1,500 to $3,000, but the cost can fall far below or above that range. Prices will vary based on the puppy's lineage, appearance, health, and the breeder. It's also possible to adopt an older Yorkie for significantly less through a rescue shelter. yorkie for sale

    ReplyDelete
  7. Are Yorkies high maintenance?
    https://www.newdaypuppies.com/teacup-yorkie-puppies-for-sale/
    The spunky Yorkshire Terrier has a lot going for him, but his beautiful coat is high-maintenance, even if clipped short. yorkie puppy for sale near me A Yorkie with a long coat requires daily brushing and weekly baths. ... Yorkies for sale near me don't shed much compared with some other dogs, but they aren't hypoallergenic.

    Are Yorkies hard to train?
    Are Yorkies easy to train? yorkie poo for sale are not the easiest breed to train. It's not because they aren't smart; they are quite an intelligent breed. But they tend to be confident, curious, and a bit stubborn—all of which can make training more difficult.

    Are Yorkies smart?
    So, are Yorkies smart? Yorkshire Terriers are highly intelligent dogs. According to canine psychologist Stanley Coren, are “above average” intelligent dogs. yorkies puppy for sale In fact, they're ranked the 34th smartest dog breed out of 138 qualifying breeds.


    ReplyDelete
  8. Do Yorkshire Terriers bite?
    Puppies bite beginning at a very young age. They learn this behavior while still with their littermates, long before you bring your Yorkie puppy into your home. yorkshire puppies for sale If the biting can be corrected while a Yorkie is still a puppy, training works best. ... This will be very similar to when a puppy yelps in pain. teacup chihuahuas for sale

    What are Teacup Yorkies?
    Teacup Yorkie is a smaller version of the same pure breed Yorkie, also known as Toy Yorkie or Micro Yorkshire Terrier. It's a tiny dog breed at about 5 to 7 inches tall, weighing between 2 to 4 pounds. The average lifespan of the Teacup Yorkie is around 12 years. yorkie terrier for sale

    Why do they cut Yorkies tails off?
    https://www.newdaypuppies.com/teacup-yorkie-puppies-for-sale/
    The main reason that Yorkie tails are docked are for aesthetic purposes. The natural tail is long and sticks up beyond the height of the head. A docked Yorkie has a tail that sticks straight up below the level of the head, which creates clean lines when the hair is worn at show length. yorkies puppy for sale

    ReplyDelete
  9. Are Yorkies good for first time dog owners?
    yorkshire terrier for sale
    The Yorkshire terrier is a great starter dog for those who want a little lap dog. This breed is affectionate towards its owner and may even act protective around strangers. teacup yorkie puppies for sale The Yorkie has a moderate energy level and only needs basic exercise.

    Are Yorkie Poo good for first time owners?
    tea cup yorkie puppy for sale
    It is the ideal pet for people who don't want to deal with pet fur at home or in their cars. This is the ideal pet for first time dog owners, since it trains easily and needs only moderate grooming maintenance. Yorkie poos are good with kids. It will play with them, is energetic and affectionate.

    Are Yorkie hypoallergenic? Yes
    yorkshire terrier for sale near me
    How much does a Yorkie Poo puppy cost?
    Yorkie Poo puppies range in price from $1,000 to $3,500, depending on the puppy's coloring and the breeder.

    Are Yorkie Poos good dogs?
    yorkie terrier puppy for sale near me
    The Yorkipoo is a gentle and loving dog who can do well with children. He's not recommended for homes with very young children, since he can be easily injured when improperly handled. A Yorkipoo can make an excellent companion for an older, more considerate child.

    ReplyDelete
  10. Do Yorkie Poos get along with cats?
    yorkies for sale
    While most Yorkies do great with cats, there are always going to be some instances where it just does not work out. Of course, it is best if you go plan for this rare but possible circumstances in which the only answer is, unfortunately, to keep them separate at all times or to find a new home for one of them. yorkie puppy for sale near me

    Do Yorkshire terriers bark a lot?
    Yorkshire Terriers are little dogs with huge personalities. With those huge personalities come a fierce territorial bark. Any time your phone rings, someone speaks or knocks on your door, or your doorbell chimes, your Yorkshire Terrier will likely bark. Outside noises aren't even required for barking for some Yorkies. yorkie for sale near me

    Are Yorkies hard to train?
    Are Yorkies easy to train? Yorkies are not the easiest breed to train. yorkie poo for sale It's not because they aren't smart; they are quite an intelligent breed. But they tend to be confident, curious, and a bit stubborn—all of which can make training more difficult. yorkie for sale


    ReplyDelete
  11. Wow. It is a very trending topic. I read many articles on this topic. But, selecting words in this articles is very good. A visa for Turkey from US is especially for the US Citizen. It is a fast and secure way of visa for USA Citizens.


    ReplyDelete

Featured Post

Yammer Embed code

 Yammer Embed code   1. IFrame: <iframe name="embed-feed" title="Yammer" src=https://web.yammer.com/embed/groups/dHlw...

Popular posts