Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 4110

How to share typescript types between nestjs backend and react frontend?

$
0
0

Let's say I have a /createPost POST endpoint in my nestjs backend. The request and response object should be fully typed in the backend via the DTO. However, how do I bring these types into the frontend? I would like to have a typed post request object, so I can not enter invalid fields or missing fields in the post body. I would also like to have a typescript interface for the response. I want to REUSE the code from the backend. What's the best way to go about this? Is there some sort of type generator library?


Viewing all articles
Browse latest Browse all 4110

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>