wasp-lang / wasp

The fastest way to develop full-stack web apps with React & Node.js.
https://wasp-lang.dev
MIT License
13.85k stars 1.19k forks source link

Make it harder to make a mistake of using normal axios or fetch to call Wasp custom APIs #2350

Open Martinsos opened 1 month ago

Martinsos commented 1 month ago

It is easy to miss the fact that you need to use our api from wasp/client/api to performa authenticated API requests toward Wasp custom APIs that you defined. We should somehow make that more obvious.

Maybe at the place where auth: and authRequired are documented, also mention that they need to use wasp/client/api? Or waht if we monkey-patched axios and fetch, only in dev, to warn you if you try to use them to access custom APIs? Ha that is a bit wild, probably too wild / intrusive, even if only during dev. What if we provided even stronger sdk for this -> we could not give you just api from wasp/client/api, but give you already typed functions to call specific apis. So incentive would be stronger to use this.

Anyway we should make this more prominent in the docs, I am sure there is some space to do that, and then it would be interesting to also do something in the Wasp itself.

Martinsos commented 1 month ago

Example of user getting confused with this https://discord.com/channels/686873244791210014/1297094807688056895/1297988337319284827 .