create-client icon indicating copy to clipboard operation
create-client copied to clipboard

TypeError: Cannot read property 'status' of undefined on generating frontend code

Open christoph-hautzinger opened this issue 7 years ago • 6 comments

Hallo I'm trying to get the client code generator running:

I have an api which returns something like this:

christophs-mbp:test htz$ curl http://handicap-berechnen.lo/api
{"@context":"\/api\/contexts\/Entrypoint","@id":"\/api","@type":"Entrypoint","club":"\/api\/clubs","course":"\/api\/courses","teeBox":"\/api\/tee_boxes"}

but running the generator results in an error:

christophs-mbp:test htz$ generate-api-platform-client http://handicap-berechnen.lo/api src
TypeError: Cannot read property 'status' of undefined
    at /Users/christophhautzinger/.config/yarn/global/node_modules/@api-platform/api-doc-parser/lib/hydra/parseHydraDocumentation.js:295:134
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)

the same error as on any non existant api endpoint url:

calling the demo code works:

christophs-mbp:test htz$ generate-api-platform-client https://demo.api-platform.com src/
Code for the "Review" resource type has been generated!
Paste the following definitions in your application configuration:

// import reducers
import review from './reducers/review/';

//import routes
import reviewRoutes from './routes/review';

// Add the reducer
combineReducers(review,{/* ... */}),

// Add routes to <Switch>
{ reviewRoutes }

Code for the "Book" resource type has been generated!
Paste the following definitions in your application configuration:

// import reducers
import book from './reducers/book/';

//import routes
import bookRoutes from './routes/book';

// Add the reducer
combineReducers(book,{/* ... */}),

// Add routes to <Switch>
{ bookRoutes }

my node version is

christophs-mbp:test htz$ node -v
v9.3.0

Do i need some special kind of configuration? didn't get it from the docs.

christoph-hautzinger avatar Dec 29 '17 21:12 christoph-hautzinger

try to run this on your api https://www.npmjs.com/package/api-platform-doc-parsing-check

mysiar avatar Dec 31 '17 06:12 mysiar

thanks for your reply!

actually, it is the same problem:

christophs-mbp:frontend htz$ node node_modules/api-platform-doc-parsing-check/lib/index.js https://handicap-berechnen.lo/api
TypeError: Cannot read property 'status' of undefined
    at /private/var/www/handicap-berechnen.de/frontend/node_modules/api-doc-parser/lib/hydra/parseHydraDocumentation.js:278:134
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)

the demo api runs smoothly:

christophs-mbp:frontend htz$ node node_modules/api-platform-doc-parsing-check/lib/index.js https://demo.api-platform.com

Checking documentation parsing for API @ https://demo.api-platform.com
[ 'books', 'reviews' ]
Number of endpoints parsed : 2

christoph-hautzinger avatar Dec 31 '17 13:12 christoph-hautzinger

you must have a problem with your son api documentation. Try postman to see what do you get for documentation and compare with demo api

mysiar avatar Jan 03 '18 09:01 mysiar

Got the same error while following Book/Review tutorial. What is postman?

danaki avatar Apr 14 '18 00:04 danaki

@danaki https://www.getpostman.com

mysiar avatar Apr 17 '18 10:04 mysiar

Hallo I'm trying to get the client code generator running:

I have an api which returns something like this:

christophs-mbp:test htz$ curl http://handicap-berechnen.lo/api
{"@context":"\/api\/contexts\/Entrypoint","@id":"\/api","@type":"Entrypoint","club":"\/api\/clubs","course":"\/api\/courses","teeBox":"\/api\/tee_boxes"}

but running the generator results in an error:

christophs-mbp:test htz$ generate-api-platform-client http://handicap-berechnen.lo/api src
TypeError: Cannot read property 'status' of undefined
    at /Users/christophhautzinger/.config/yarn/global/node_modules/@api-platform/api-doc-parser/lib/hydra/parseHydraDocumentation.js:295:134
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)

the same error as on any non existant api endpoint url:

calling the demo code works:

christophs-mbp:test htz$ generate-api-platform-client https://demo.api-platform.com src/
Code for the "Review" resource type has been generated!
Paste the following definitions in your application configuration:

// import reducers
import review from './reducers/review/';

//import routes
import reviewRoutes from './routes/review';

// Add the reducer
combineReducers(review,{/* ... */}),

// Add routes to <Switch>
{ reviewRoutes }

Code for the "Book" resource type has been generated!
Paste the following definitions in your application configuration:

// import reducers
import book from './reducers/book/';

//import routes
import bookRoutes from './routes/book';

// Add the reducer
combineReducers(book,{/* ... */}),

// Add routes to <Switch>
{ bookRoutes }

my node version is

christophs-mbp:test htz$ node -v
v9.3.0

Do i need some special kind of configuration? didn't get it from the docs.

Hello, have you found a solution ? i the same error

faso-dev avatar Feb 25 '20 20:02 faso-dev