Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用 axios 发送POST 请求时,无法正常接收到数据 #138

Open
3DMXM opened this issue Aug 11, 2022 · 2 comments
Open

使用 axios 发送POST 请求时,无法正常接收到数据 #138

3DMXM opened this issue Aug 11, 2022 · 2 comments

Comments

@3DMXM
Copy link

3DMXM commented Aug 11, 2022

ts 请求代码
function GetUser() { axios.post("/render/GetUser", { user: "111" }).then((res: any) => { console.log(res); }) }

PHP接收代码
public function action_GetUser(){ $user = $this->request->post("user"); $this->json([ "code"=>"00", "user"=>$user ]); }

请求返回
{"code":"00","user":null}

QQ截图20220811113747
QQ截图20220811113804
QQ截图20220811113908
QQ截图20220811113917

@billge1205
Copy link
Collaborator

看起来你这个并不是表单形式(x-www-form-urlencoded)的post参数格式,而是json格式的
可以尝试用 $this->request->json('user') 获取看看呢

@3DMXM
Copy link
Author

3DMXM commented Aug 11, 2022

恩,$this->request->json('user') 可以获取到了,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants