Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

TypeError: Cannot read property 'username' of undefined #48

Open
decentral1se opened this issue Mar 19, 2020 · 3 comments
Open

TypeError: Cannot read property 'username' of undefined #48

decentral1se opened this issue Mar 19, 2020 · 3 comments

Comments

@decentral1se
Copy link
Contributor

When I run curl -X POST -d '{"username": "foo", "password": "bar"}' https://myhomebase.foo/v1/accounts/login and with the following .homebase.yml configuration:

webapi:
  domain: myhomebase.foo
  username: foo
  password: bar

I keep receiving a HTTP 500 and seeing TypeError: Cannot read property 'username' of undefined.

I'm on homebase 2.0.8.

@decentral1se
Copy link
Contributor Author

decentral1se commented Mar 19, 2020

Seems like the relevant check is:

if (!(req.body.username === config.webapi.username && req.body.password === config.webapi.password)) {

Something wrong with my request format? Seems like req.body.username blows up.

@pfrazee
Copy link
Member

pfrazee commented Mar 23, 2020

Code should probably check if req.body is a non-null object so that it gives a better error message. Not sure why your request is failing, maybe the content-type header is wrong?

@decentral1se
Copy link
Contributor Author

Aha, I see, I'll try with the correct headers.

I'll leave this open to track better error messages.

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

No branches or pull requests

2 participants