我正在尝试将 GET 请求作为第二个参数发送,但是当它作为 url 时它不起作用。
这有效, $_GET['naam'] 返回测试:
export function saveScore(naam, score) {
return function (dispatch) {
axios.get('http://****.nl/****/gebruikerOpslaan.php?naam=test')
.then((response) => {
dispatch({type: "SAVE_SCORE_SUCCESS", payload: response.data})
})
.catch((err) => {
dispatch({type: "SAVE_SCORE_FAILURE", payload: err})
})
}
};
但是当我尝试这个时,根本没有任何东西$_GET
:
export function saveScore(naam, score) {
return function (dispatch) {
axios.get('http://****.nl/****/gebruikerOpslaan.php',
{
password: 'pass',
naam: naam,
score: score
})
.then((response) => {
dispatch({type: "SAVE_SCORE_SUCCESS", payload: response.data})
})
.catch((err) => {
dispatch({type: "SAVE_SCORE_FAILURE", payload: err})
})
}
};
为什么我不能这样做?在文档中它清楚地表明这是可能的。有了$_POST
它也不起作用。