phongyewtong
phongyewtong

Reputation: 5319

Firebase onCall request fail on chrome browser?

I deployed this and tried to call it on my browser using the url given by firebase cmd. Is it possible to call onCall on browser or do I need to call it from a client?

exports.test = functions.https.onCall((input, context) => {
    // res.status(200).json({results: "Success"})
    console.log("test")
    return { status: 200, message: "Success"}
})

Got this error

{
  "error": {
    "message": "Bad Request",
    "status": "INVALID_ARGUMENT"
  }
}

Upvotes: 1

Views: 117

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317750

The URL of a callable function cannot be used to directly access it. A callable function has a specific protocol used to pass data back and forth. If the client doesn't implement that protocol, the request won't work.

If you want direct browser access without a special protocol, you should write an regular HTTP function using onRequest instead of a callable.

Upvotes: 2

Related Questions