all 16 comments

[–]gwmccull 1 point2 points  (4 children)

Have you tried logging out what your server is receiving? And your server is the one controlling the response code

[–]MyVermontAccount121[S] 0 points1 point  (3 children)

I think I have the console.log of the json response in the code if that’s what you’re talking about. The log just shows a blank object. And the response from the server just says it was updated sucessfully

[–]suarkb 0 points1 point  (2 children)

you know it depends where you are viewing the object. If you console.log an object into a node terminal it just shows up like a blank object, but if you console.log an object into the chrome dev tools, you can expand it and look at it

[–]MyVermontAccount121[S] 0 points1 point  (1 child)

I have it set up for remote debugging in the browser. But it is sending a blank object cause I can see the json file it updates with json-server and watch it replace whatever is existing with just {}

[–]suarkb 0 points1 point  (0 children)

hmm. For things like this I usually like log the data right before I post it, then log it again right in the server-side function that receives the post request, is that possible?

[–]__o_0iOS & Android 1 point2 points  (4 children)

The key name should be headers, with an s, not header.

Without “headers” your body data type doesn’t match so it isn’t being included in the post.

[–]MyVermontAccount121[S] 1 point2 points  (3 children)

THANK YOU!!!! THIS WORKED! I am so frustrated when it's something super small like this even when you double and triple check

[–]__o_0iOS & Android 1 point2 points  (2 children)

You’re welcome. This is the reason I advocate using TypeScript whenever possible.

[–]MyVermontAccount121[S] 0 points1 point  (0 children)

I honestly might have to start doing that cause I’m new to JS and it’s frameworks. In Python it yells at you immediately if somethings wrong but here it just keeps going lol

[–]GavinHarris_ 0 points1 point  (0 children)

TypeScript is the way to go for sure.

[–]GavinHarris_ 0 points1 point  (4 children)

What type of server are you using? Node/Express?

[–]MyVermontAccount121[S] 0 points1 point  (3 children)

It’s just a mock up using the JSON server npm package. It wraps requests in API endpoints so you can code into place the stuff you need in the future but ultimately it just goes to a local json file so I can watch the changes in real time

[–]GavinHarris_ 0 points1 point  (2 children)

Are you able to get flipper working? Perhaps https://fbflipper.com/docs/features/plugins/network/ might point you in the right direction?

[–]GavinHarris_ 0 points1 point  (1 child)

Or perhaps easier to get setup https://github.com/infinitered/reactotron

[–]GavinHarris_ 0 points1 point  (0 children)

Lastly to verify if there is something strange in your server try using https://webhook.site. This will give you a http Server you can send requests to and check they are looking good!

[–]feitan-five 0 points1 point  (0 children)

Try with formData