Thursday, June 13, 2024
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.

the authortherichpost
Hello to all. Welcome to Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 14, Angular 15, Angular 16, Angular 17, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

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