apipeline icon indicating copy to clipboard operation
apipeline copied to clipboard

How to post raw data as JSON

Open thamizh82 opened this issue 7 years ago • 2 comments

Hi,

I need to post raw JSON data in fetch api without using JSON.stringify() in body.

thamizh82 avatar Mar 19 '18 04:03 thamizh82

Hi, I haven't tried it, but you should be able to do it like this

        api.fetch(
            'yourService',
            {
                fetchOptions: {
                    body: yourJsonData
                }
            }
        )

fetchOptions basically allows you to tweak the final request options with all the configuration you'd use when using react-native's fetch directly. So this shouldn't be tied to react-native-offline-api.

Exilz avatar Mar 20 '18 10:03 Exilz

In my case fetch method appends utf8 like this "application/json; charset=utf-8". how to solve this by not appending utf8.

Thanks

thamizh82 avatar Mar 20 '18 10:03 thamizh82