当前位置: 首页 > 工具软件 > Reqwest > 使用案例 >

react+reqwest+post20180611

刘令
2023-12-01

ReactReqwestpost请求方式的使用

一、前端代码(加个headers

headers: {
  "Content-Type": "application/json",
  // "Access-Control-Request-Headers": "Origin, X-Requested-With, Content-Type, Accept"
},

 

二、后端代码(也加请求头)

1.

 

2.

3.代码:

4.// 允许跨域访问

5.        header('Access-Control-Allow-Origin: *');

6.        header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method, Authorization");

7.        header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");

 

三、使用

 

 类似资料: