2

I would send POST request from react frontend to php backend. Here is code.

--frontend

fetch(backendUrl + "/list", {
    method: "POST",
    headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify(filterData)
})
.then(function(res) {
    return res.json()
})
.then(function(data) {
    self.setState({
        OddList: data.list
    });
    self.props.setPageCount(data.page_count);
    self.props.onShowLoading(false);
})
sudo
  • 906
  • 2
  • 14
  • 32
Mike Will
  • 43
  • 1
  • 5

1 Answers1

1

It 's mentioned in the comments that you have a different domain for the PHP API you are using. I think the problem is there.

If you use this way the request will go to something similar to bellow URL

ex

http://frontendappdomain/backendurl/list

While you actually want to hit something similar to bellow URL

http://phpappdomaint/backendurl/list

Try sending the full URL instead of the "pathname". That would solve your problem if I understood your problem correctly.

Shashith Darshana
  • 2,715
  • 1
  • 25
  • 27