热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

fetch请求的疑问?

前端是用的fetch,后端是express框架,fetch请求如下:`fetch(http://127.0.0.1:8080/userlogin,{

前端是用的fetch,后端是express框架,fetch请求如下:
`

fetch('http://127.0.0.1:8080/userlogin', {

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
    method: 'post',

    headers: {

      'Content-Type': 'application/json',



    },

    mode:'no-cors',

    body: JSON.stringify(values),

  })

    .then((response) => {



      return response.text()

    })

    .then((responseData) => {

      alert(responseData);



    })

    .catch((error) => {

      console.error('error', error)

    });

`
chrome里面看到的contentType怎么还是text

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Request Headers

Accept:*/*

Accept-Encoding:gzip, deflate, br

Accept-Language:zh-CN,zh;q=0.8

Connection:keep-alive

Content-Length:39

content-type:text/plain;charset=UTF-8

Host:127.0.0.1:8080

Origin:http://localhost:8000

Referer:http://localhost:8000/login

User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36

Request Payload

view source

{username: "guest", password: "guest"}

password

:

"guest"

username

:

"guest"

明明发送时候写的是 application/json ,怎么header是text?


推荐阅读
author-avatar
小小蜘蛛侠
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有