PaulChess / MyBlog

1 stars 0 forks source link

Note 笔记 #36

Open PaulChess opened 2 years ago

PaulChess commented 2 years ago

一些随手记

PaulChess commented 2 years ago

fetch 函数:

fetch('xxx', {
  method: 'post',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify({"query":"{bondService(commonInput:{codes:\"33(300033)\"}){bond_name bond_seccode}}"})
})
.then(v => v.json())
.then((response) => {
  console.log('response====')
  console.log(response.data.bondService)
})

headers 里需要加 Accept: 'application/json', 才能拿到实际返回的数据,否则 response 打印出来始终是个 promise