我如何从模拟器测试云功能?
How can i test from the emulator a cloud function?
我有这样的云功能
exports.isWhite = functions.https.onRequest((request, response) => {
return cors(request, response, async () => {
try {
const { query } = request
let { address } = query
address = address.toLowerCase()
但我不知道如何从模拟器测试它?
我把这个 url http://localhost:5001/roor-dev-ff624/us-central1/isWhitelisted 放在我的浏览器上,我怎样才能传递地址?因为我收到这个错误:
"[ !!! ] Error: TypeError: Cannot read property 'toLowerCase' of undefined\n
您正在查找 Query String 个参数。要以这种方式传递地址,请尝试将 URL 更改为:
http://localhost:5001/roor-dev-ff624/us-central1/isWhitelisted?address=some_address
您可以使用 optional chaining 来避免该错误:
const address = request.query.address?.toLowerCase();
我有这样的云功能
exports.isWhite = functions.https.onRequest((request, response) => {
return cors(request, response, async () => {
try {
const { query } = request
let { address } = query
address = address.toLowerCase()
但我不知道如何从模拟器测试它?
我把这个 url http://localhost:5001/roor-dev-ff624/us-central1/isWhitelisted 放在我的浏览器上,我怎样才能传递地址?因为我收到这个错误:
"[ !!! ] Error: TypeError: Cannot read property 'toLowerCase' of undefined\n
您正在查找 Query String 个参数。要以这种方式传递地址,请尝试将 URL 更改为:
http://localhost:5001/roor-dev-ff624/us-central1/isWhitelisted?address=some_address
您可以使用 optional chaining 来避免该错误:
const address = request.query.address?.toLowerCase();