Javascript 获取POST请求不存在';t返回使用res.send(';sampletext';)发送的响应;

Javascript 获取POST请求不存在';t返回使用res.send(';sampletext';)发送的响应;,javascript,reactjs,firebase,google-cloud-functions,fetch-api,Javascript,Reactjs,Firebase,Google Cloud Functions,Fetch Api,我有一个云函数,它是使用来自客户端浏览器的fetch POST请求触发的,但是对fetch调用的响应不包含来自云函数的响应文本(res.send(“sampletext”)) 云功能: const functions = require('firebase-functions'); const cors = require('cors')({ origin: true }) exports.unlock = functions.https.onRequest((req, res) =>

我有一个云函数,它是使用来自客户端浏览器的fetch POST请求触发的,但是对fetch调用的响应不包含来自云函数的响应文本(res.send(“sampletext”))

云功能:

const functions = require('firebase-functions');
const cors = require('cors')({ origin: true })

exports.unlock = functions.https.onRequest((req, res) => {
    cors(req, res, () => {
        res.send('bsdasda');
    })
})
在客户端浏览器上获取POST请求

fetch("https://us-central1-closing-ratio-32360.cloudfunctions.net/unlock", {
  method: "post",
  mode: "cors"

}).then((response) => {
  console.log(response)
});
Response {type: "cors", url: "https://us-central1-closing-ratio-32360.cloudfunctions.net/unlock", redirected: false, status: 200, ok: true, …}
body
:
(...)
bodyUsed
:
false
headers
:
Headers {}
ok
:
true
redirected
:
false
status
:
200
statusText
:
""
type
:
"cors"
url
:
"https://us-central1-closing-ratio-32360.cloudfunctions.net/unlock"
__proto__
:
Response
这是客户端浏览器上的获取响应

fetch("https://us-central1-closing-ratio-32360.cloudfunctions.net/unlock", {
  method: "post",
  mode: "cors"

}).then((response) => {
  console.log(response)
});
Response {type: "cors", url: "https://us-central1-closing-ratio-32360.cloudfunctions.net/unlock", redirected: false, status: 200, ok: true, …}
body
:
(...)
bodyUsed
:
false
headers
:
Headers {}
ok
:
true
redirected
:
false
status
:
200
statusText
:
""
type
:
"cors"
url
:
"https://us-central1-closing-ratio-32360.cloudfunctions.net/unlock"
__proto__
:
Response
看看这个:

fetch("https://us-central1-closing-ratio-32360.cloudfunctions.net/unlock", {
  method: "post",
  mode: "cors"
})
.then((response) => response.text())
.then((text) => {
  console.log(text)
});