2021年1月22日星期五

Folder structure with React and Wordpress

In my local MAMP setup I have this folder structure:

react_wordpress (Wordpress install)

  • frontend (create-react-app project)
  • index.php
  • wp-content
  • wp-admin
  • wp-includes
  • etc...

So now I can visit mywebsite.com and visit the Wordpress site.

I can npm start and see my react app on localhost:3000

How do I access "mywebsite.com/wp-json/wp/v2/posts" from my react project now?

This code below throws a CORS error in my App.js

fetch('http://mywebsite.com/wp-json/wp/v2/posts')    .then(res => {      console.log( res );    })    .then(data => {      console.log( data );    })  
https://stackoverflow.com/questions/65853744/folder-structure-with-react-and-wordpress January 23, 2021 at 06:44AM

没有评论:

发表评论