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

Calling wrong api end point

Open napestershine opened this issue 6 years ago • 7 comments

HI

I had a symfony app, so I added APIResource on entity. Now I API's are working perfectly. But Client generated app for react is always calling wrong API. For example: If I have a resource faq. It is supposed to call http://localhost:8000/api/faqs but it's calling http://localhost:8000/faqs.

In my entrypoint.js I have Base URL as http://localhost:8000/api

What's getting wrong there?

Thanks

napestershine avatar May 11 '19 08:05 napestershine

Looks related to #107. Can you try to set http://localhost:8000/api/ (with a trailing slash) as base url? It should be fixed by https://github.com/api-platform/client-generator/blob/master/src/index.js#L51-L53 but it doesn't seem to work properly.

dunglas avatar May 11 '19 08:05 dunglas

exactly. I am scratching my head since 3 days. and URL's are not working properly.

napestershine avatar May 11 '19 08:05 napestershine

Does adding the trailing slash in entrypoint.js fixes the problem?

dunglas avatar May 11 '19 08:05 dunglas

yes. Works perfectly. Then why it generated by default without /

napestershine avatar May 11 '19 09:05 napestershine

It’s definitely a bug. A patch would be very appreciated!

dunglas avatar May 11 '19 09:05 dunglas

A fix could be made by generalizing the change made in #115 (currently done for the VueJS part only)

Deuchnord avatar May 11 '19 09:05 Deuchnord

It should be handled in the generator, not in the generated code.

dunglas avatar May 11 '19 09:05 dunglas

I'm a bit confused by the timeline but it has been fixed in this PR

J3m5 avatar Mar 30 '24 17:03 J3m5