API에 로그인 양식을 제출하려고하는데 API가 사후 요청 테스트를 통과하지 못합니다.ReactJS AXIOS 게시가 작동하지 않습니다.
ReactJS 작업 :
/**
* Sends login request to API
*/
export function login(email, password) {
console.log('Credentials:', email, password)
const request = axios.post(`${ROOT_URL}login/login`,
{
email,
password
})
.then((response) => console.log(response))
.catch((error) => console.log(error));
}
로그인 기능 API에서 :
public function actionLogin($credentials = [])
{
$request = Yii::$app->request;
if ($request->post()) {
// handle the user login
} else {
return Json::encode(['status' => false, 'data' => 'error_no_request']);
}
}
콘솔이 응답을 로그인은 - 그것이 요청 테스트를 통과하지 않는 분명하다.
헤더 : 요청을 기록
Response Headers
Access-Control-Allow-Origin:*
Connection:Keep-Alive
Content-Length:42
Content-Type:text/html; charset=UTF-8
Date:Wed, 20 Sep 2017 06:42:06 GMT
Keep-Alive:timeout=5, max=98
Server:Apache/2.4.18 (Win32) OpenSSL/1.0.2e PHP/7.0.8
X-Powered-By:PHP/7.0.8
Request Headers
Accept:application/json, text/plain, */*
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:56
Content-Type:application/json;charset=UTF-8
Host:127.0.0.1
Origin:http://localhost:8080
Referer:http://localhost:8080/login
'API가 요청을받지 못했습니다.'그 사진이 무엇입니까? XMLHttpRequest가 200 응답 상태 인 것 같습니다. –
잘못된 것 같습니다. 요청을 받지만 로그인 처리 부분에 도달하지 않습니다. –