✅ Typescript form sending model empty to C# API layer
hey guys, I have these samples here:
My React/Typescript POST method
My C# Post controller:
Models:
- Typescript
- C#
Yes, the product variable is not empty when I'm debugging but for some reason when it goes for the CreateProduct route in C# it's empty, all fields are null.
Any ideas?
7 Replies
btw im using entity framework for my api, and its working cuz ive made few attempts direct to swagger so i dont think the problem is in fact direct on the api side but maybe some sorta of gateway from node/browser side to my endpoints prob like cors or smth like that (i also already configured cors tho)
for more context heres the repo https://github.com/notgonnaleo/night-alternative/tree/develop
Right now you're sending an equivalent of
You want to strip that outer model
Since the API doesn't expect it
Either post
product
instead of { product }
Or spread the object
so just this is already enough?
hmm ight ight, thanks man im going to give it a try and let you know if it did work one sec
got it thanks bro u r a life saver
it was the model thing u said and i also added one of the props with the wrong type and it was conflicting when sending to the other layer
thanks bro
Nice, easy fixes are the best lol
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.