0

私は、クライアントブラウザからPOSTリクエストを取得することでトリガされるクラウド機能を持っていますが、フェッチコールに対するレスポンスにはクラウド機能(res.send( "sampletext"))のレスポンステキストは含まれていません。POSTリクエストを取得しても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 

答えて

1

チェックこのアウト:

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