Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase HTTP Cloud function query data undefined #1345

Closed
abdullah-web-dev opened this issue May 29, 2019 · 5 comments
Closed

Firebase HTTP Cloud function query data undefined #1345

abdullah-web-dev opened this issue May 29, 2019 · 5 comments

Comments

@abdullah-web-dev
Copy link

I've been trying to run the firebase cloud HTTP function locally on my computer.
When I try to send the query data to the http function locally then it is undefined.

Windows 10 is being used.

The function is:

export const checkHttp = functions.https.onRequest((req,res)=>{
    const id = req.query.id == undefined ? "undefined" : req.query.id
    res.send({
        "ID":id
    })
})

The command I used to start the emulation for functions is:
firebase serve --only functions

The url for local emulation is returned as
http://localhost:5000/..../checkHttp

Now even if I pass the url with the following
http://localhost:5000/..../checkHttp?id=123 //anything

The response is:

{ "ID" : "undefined" }

But when I deploy that function and use that deployed url then it works fine

for example if I run the same query on the deployed function then the result is correct:
URL: https://us-central1-..../checkHttp?id=123
Response:

{ "ID" : 123 }

The package.json is as follows

{
  "name": "functions",
  "scripts": {
    "lint": "tslint --project tsconfig.json",
    "build": "tsc",
    "serve": "npm run build && firebase serve --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "10"
  },
  "main": "lib/index.js",
  "dependencies": {
    "firebase-admin": "8.0.0",
    "firebase-functions": "^2.3.1",
    "grpc": "^1.21.1"
  },
  "devDependencies": {
    "firebase-functions-test": "^0.1.6",
    "tslint": "^5.12.0",
    "typescript": "^3.2.2"
  },
  "private": true
}
@thechenky
Copy link
Contributor

Hi @abdullahamin0111 thanks for filing. What version of the Firebase CLI are you using? This may be related the the new emulators that were released in the CLI starting with v6.9.0. Does this work locally for you if you downgrade your firebase-tools to 6.8.0?

@thechenky thechenky self-assigned this May 29, 2019
@thechenky
Copy link
Contributor

I'm going to go ahead and move this issue over to the Firebase CLI repo as firebase serve is implemented there.

@thechenky thechenky transferred this issue from firebase/firebase-functions May 29, 2019
@thechenky
Copy link
Contributor

@abeisgoat @samtstern would you mind taking a look at this? Thanks!

@abdullah-web-dev
Copy link
Author

The response works perfectly when firebase-tools are downgraded....

Version that was giving error was: 6.10.0
The version that now runs perfectly: 6.8.0

Thanks.

@samtstern
Copy link
Contributor

This was fixed by #1332 and will be included in the next release. Thanks for your patience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants