Php Reactjs-axios post请求不存在';t工作-找不到404
查看了有关此问题的一些答案,但无法解决 Axios调用无法识别PHP URL。 它返回404 这是我的行动创造者:Php Reactjs-axios post请求不存在';t工作-找不到404,php,reactjs,axios,Php,Reactjs,Axios,查看了有关此问题的一些答案,但无法解决 Axios调用无法识别PHP URL。 它返回404 这是我的行动创造者: import { GET_ALL_LECTURERS } from './consts' import axios from "axios"; const baseUrl = 'http://localhost:3000/api'; export const getAllLecturers = () => { let url = `${
import {
GET_ALL_LECTURERS
} from './consts'
import axios from "axios";
const baseUrl = 'http://localhost:3000/api';
export const getAllLecturers = () => {
let url = `${baseUrl}/lec.php`;
return dispatch => {
axios
.get(url)
.then(function (response) {
dispatch({ type: GET_ALL_LECTURERS, value: response.data });
})
.catch(function (error) {
console.log(error);
});
};
};
这是文件位置图像。
我缺少什么?您的React应用程序在dev server中工作。PHP不会在该服务器上工作,PHP应该托管在支持PHP文件的服务器上(例如:Apache服务器)整个文件夹位于
D:\xampp\htdocs\react\achvagen\api`如果我直接使用127.0.0.1\react\achvagen\api\lec.php'调用该文件,我可以看到它的输出。我没有解决问题,但我成功地使用了这个urlconst baseUrl='http://127.0.0.1/react/achvagen/api';
这意味着你的baseUrl不正确,应该是http://localhost/react/achvagen/api
或http://127.0.0.1/react/achvagen/api
如您所提供