下载querystring解析对象变为对象

    1. yarn add querystring
    1. import React, { Component } from 'react'
    2. import qs from 'querystring'
    3. export default class index extends Component {
    4. postHttp=()=>{
    5. fetch("http://iwenwiki.com/api/blueberrypai/login.php",{
    6. method:"POST",
    7. headers:{
    8. "Content-Type":"application/x-www-form-urlencoded",
    9. "Accept":"application/json,text/plain,*/*"
    10. },
    11. body:qs.stringify({
    12. user_id:"iwen@qq.com",
    13. password:"iwen123",
    14. verification_code:"crfvw"
    15. })
    16. }).then(res=> res.json()
    17. ).then(data=>{
    18. console.log(data)
    19. })
    20. }
    21. render() {
    22. return (
    23. <div>
    24. 我是fetch
    25. <button onClick={this.postHttp}>发送post请求</button>
    26. </div>
    27. )
    28. }
    29. }