繁体   English   中英

$this->request->getPost('email') 在执行 axios POST 请求时不提供任何值

[英]$this->request->getPost('email') doesn't give any value while doing axios POST request

我正在使用 axios 发出 HTTP 请求 POST。 这是我要请求的 axios 代码

async onFormSubmit(input_data){    
  const response = await axios.post('http://localhost:8080/auth/login', {
    email: input_data['email'],
    password: input_data['password']
  });

之后在后端我使用 codeigniter 4 并使用此代码获取发布请求的值

return json_encode($this->request->getPost('email'));

然后数据返回为Null。 如何从 axios post 接收 post 数据?

铌:

  1. 我直接返回数据只是为了直接找axios贴出来的值
  2. input_data['email'] 的值不是 None (在执行 axios post 之前已经在控制台中检查过)

[已解决] 使用 getJson 而不是 getPost

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM