ReactjsRest Api Wp

Reactjs fetch data from wordpress

Reactjs fetch data from wordpress


Hello, welcome to In this post, I will tell you, Reactjs fetch data from wordpress. Reactjs is a Javascript Library to build user interface.

This is data coming from wordpress in reactjs app index.html file:


In this post, I will tell you, how to fetch data from wordpress(wordpress user) with reactjs. In my app, we will use react js as frontend and wordpress as backend.

Here is working and tested code for Reactjs fetch data from wordpress and you just need to add this into your reactaApp App.jsx file:
import React from 'react';

class App extends React.Component {
constructor(props) {
    this.state = {
      error: null,
      isLoaded: false,
      items: []

  componentDidMount() {
      .then(res => res.json())
        (result) => {
            isLoaded: true,
            items: result
        // Note: it's important to handle errors here
        // instead of a catch() block so that we don't swallow
        // exceptions from actual bugs in components.
        (error) => {
            isLoaded: true,
   render() {
    const { error, isLoaded, items } = this.state;
    if (error) {
      return <div>Error: {error.message}</div>;
    } else if (!isLoaded) {
      return <div>Loading...</div>;
    } else {
      return (
export default App;

 If you have any query related to this post, then please comment below.

Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to Myself Ajay Malhotra and I am full stack developer. I love coding. I know Wordpress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, laravel, Codeigniter, Shopify, Squarespace, Jquery, Google Map Api, Vuejs, Reactjs, Bigcommerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Positive SSL