Cannot read property 'id' of undefined
See original GitHub issueI’m getting this error when trying to invoke a post transaction. I can do a get transaction with no error but if I try to do a post I get the following error:
[Nest] 19311 - 2018-10-10 08:37:20 [ExceptionsHandler] Cannot read property 'id' of undefined +138057ms
TypeError: Cannot read property 'id' of undefined
at CarService.create (/Users/simonmullaney/Desktop/hyperledger-typescript-boilerplate/src/cars/car.service.ts:59:89)
at CarController.create (/Users/simonmullaney/Desktop/hyperledger-typescript-boilerplate/src/cars/car.controller.ts:78:32)
at /Users/simonmullaney/Desktop/hyperledger-typescript-boilerplate/node_modules/@nestjs/core/router/router-execution-context.js:44:29
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
Output when application is started:
npm run start
> hyperledger-typescript-boilerplate@1.2.0 start /Users/simonmullaney/Desktop/hyperledger-typescript-boilerplate
> ts-node -r tsconfig-paths/register src/main.ts
Missing baseUrl in compilerOptions. tsconfig-paths will be skipped
[Nest] 19586 - 2018-10-10 08:39:42 [NestFactory] Starting Nest application...
debug: NODE_ENV: LOCAL
debug: PORT: 3000
debug: DOMAIN_URL: http://localhost:3000
debug: AWS_ACCESS_KEY: AKIAIH*******CWQ
debug: AWS_SECRET_ACCESS_KEY: Lee9t*****4Hb747RV
debug: AWS_REGION: us-east-1
debug: AWS_QUEUE_NAME: Block_SQS.fifo
debug: BYPASS_QUEUE: false
debug: PURGE_QUEUE_ON_STARTUP: false
debug: DEAD_LETTER_QUEUE_ARN: arn:aws:sqs:us-*****Aviation_SQS.fifo
debug: PEER_HOST: localhost
debug: ORDERER_HOST: localhost
debug: CA_HOST: localhost
debug: PUSHER_KEY: c555b0****0bc264e
debug: PUSHER_APP_ID: 6***7
debug: PUSHER_SECRET: 20f*****48070
debug: PUSHER_CLUSTER: eu
debug: AUTH0_CLIENT_ID: HAp01IdE*****po7AL2Guc
debug: AUTH0_CLIENT_SECRET: dQX41ZRWd*******Qjgn7iAUOxNhNJhPnSEo
debug: AUTH0_DOMAIN: bloc*****th0.com
debug: AUTH0_AUDIENCE: https://bloc*****m/api/v2/
debug: LOGGER_SQS_DEBUG: false
debug: SKIP_MIDDLEWARE: false
[Nest] 19586 - 2018-10-10 08:39:42 [InstanceLoader] ApplicationModule dependencies initialized +41ms
[Nest] 19586 - 2018-10-10 08:39:42 [InstanceLoader] EventsModule dependencies initialized +0ms
[Nest] 19586 - 2018-10-10 08:39:42 [InstanceLoader] QueueModule dependencies initialized +1ms
[Nest] 19586 - 2018-10-10 08:39:42 [InstanceLoader] PingModule dependencies initialized +5ms
[Nest] 19586 - 2018-10-10 08:39:42 [InstanceLoader] ChainModule dependencies initialized +3ms
[Nest] 19586 - 2018-10-10 08:39:42 [InstanceLoader] AuthenticationModule dependencies initialized +0ms
[Nest] 19586 - 2018-10-10 08:39:42 [InstanceLoader] CoreModule dependencies initialized +0ms
[Nest] 19586 - 2018-10-10 08:39:42 [InstanceLoader] CarModule dependencies initialized +1ms
[Nest] 19586 - 2018-10-10 08:39:42 [InstanceLoader] PlaneModule dependencies initialized +0ms
https://blockaviation.eu.auth0.com/authorize
http://localhost:3000/api/oauth2-redirect.html
[Nest] 19586 - 2018-10-10 08:39:42 [RoutesResolver] PingController {/}: +42ms
[Nest] 19586 - 2018-10-10 08:39:42 [RouterExplorer] Mapped {/, GET} route +3ms
[Nest] 19586 - 2018-10-10 08:39:42 [RoutesResolver] CarController {/cars}: +0ms
[Nest] 19586 - 2018-10-10 08:39:42 [RouterExplorer] Mapped {/, GET} route +1ms
[Nest] 19586 - 2018-10-10 08:39:42 [RouterExplorer] Mapped {/:id, GET} route +0ms
[Nest] 19586 - 2018-10-10 08:39:42 [RouterExplorer] Mapped {/, POST} route +1ms
[Nest] 19586 - 2018-10-10 08:39:42 [RoutesResolver] PlaneController {/planes}: +0ms
[Nest] 19586 - 2018-10-10 08:39:42 [RouterExplorer] Mapped {/, GET} route +0ms
[Nest] 19586 - 2018-10-10 08:39:42 [RouterExplorer] Mapped {/:id, GET} route +1ms
[Nest] 19586 - 2018-10-10 08:39:42 [RouterExplorer] Mapped {/, POST} route +0ms
[Nest] 19586 - 2018-10-10 08:39:42 [NestApplication] Nest application successfully started +2ms
info: Started Chain-service on PORT 3000
FileKeyValueStore {
_dir: '/Users/simonmullaney/Desktop/hyperledger-typescript-boilerplate/src/common/config/creds' }
info: Successfully instantiated HLF Client
false
false
getting user from store
userFromStore: {"name":"admin","mspid":"Org1MSP","roles":null,"affiliation":"","enrollmentSecret":"","enrollment":{"signingIdentity":"b571510ab5c45fb0d05007504f1373b47e81a0a542f4e7ba64df09b86141e716","identity":{"certificate":"-----BEGIN CERTIFICATE-----\nMIICAjCCAaigAwIBAgIUNf0Pmd/N0p7bvPb5VWzd4GeqgNQwCgYIKoZIzj0EAwIw\nczELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNh\nbiBGcmFuY2lzY28xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHDAaBgNVBAMT\nE2NhLm9yZzEuZXhhbXBsZS5jb20wHhcNMTgxMDEwMDcxODAwWhcNMTkxMDEwMDcy\nMzAwWjAhMQ8wDQYDVQQLEwZjbGllbnQxDjAMBgNVBAMTBWFkbWluMFkwEwYHKoZI\nzj0CAQYIKoZIzj0DAQcDQgAEa0rlIkqTADhoNAfHXXi0Z6tMgYSRpYbX76rWn98L\nb/4K1LFMDUSyExMe5Fjr1ZCTujFWc4ol+XLqyvqejizN06NsMGowDgYDVR0PAQH/\nBAQDAgeAMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFP9UA83vhpgl5LtfdB/69vMQ\nzo3uMCsGA1UdIwQkMCKAIEI5qg3NdtruuLoM2nAYUdFFBNMarRst3dusalc2Xkl8\nMAoGCCqGSM49BAMCA0gAMEUCIQDex3INvgI3IBBUSzEJKMhJGfS0ypnP/zEgUrwu\nhxTncwIgDH/Jl0Xte6GyGKJTzQTd+5D4QiRV894bW+efzu4q9WU=\n-----END CERTIFICATE-----\n"}}}
user
info: Assigned the admin user to the fabric client
I’m authenticating my swagger api with auth0 with no problems so I cant figure out what could be the problem - hopefully ye have seen something like this before and might be able to point me in the right direction 👍
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (4 by maintainers)
Top Results From Across the Web
Cannot read properties of undefined (reading 'id') - TrackJS
In this case, our code expects to have an object with a id property, but that object was not present.
Read more >"Cannot read property 'id' of undefined" when parsing an array ...
First, as said in the comments, you need to make sure the message object passed is really the one you're looking for.
Read more >Uncaught TypeError: Cannot read property 'id' of undefined
Uncaught TypeError : Cannot read property 'id' of undefined. It is common that object be come null value, for example when your application ......
Read more >Cannot read property 'id' of undefined Stack
Error : Cannot read property 'id' of undefined Stack. Browser being used is Chrome. Azure DevOpsAzure DevOpsboards. View timeline by. All Posts (13)...
Read more >TypeError: Cannot read property 'id' of undefined - JavaScript
I am trying to work around the problem but it seem strange as I am not proficient with JS Objects. Following is my...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Oh, I know what the issue is, gimme a sec.
Turned out it was a problem with my .env file.
I just hardcoded the values into my env.ts file instead and the error disappeared.