0

In react-native am using the fetch post method I want to send nested JSON in

method: 'POST',
headers: {
   'Accept': 'application/json',
   'Content-Type': 'application/json',
    },
body: JSON.stringify({

// send below JSON to the backend

{
  "filterCriteria": {
    "catalogId": 0,
    "filterEnabled": "false"
  }
}

2 Answers 2

1

Suppose you have JSON data then you can assign that JSON data to a variable,

const data = { "filterCriteria": { "catalogId": 0, "filterEnabled": "false" } }

And that data can be send to back-end like,

body: JSON.stringify(data)
Sign up to request clarification or add additional context in comments.

Comments

0

Just create a nested object and use it. It is not related to React Native. It is general JSON | Javascript concept.

let myData = 

{
  "filterCriteria": {
    "catalogId": 0,
    "filterEnabled": "false"
  }
};

THen use it where you want. Like;

...

method: 'POST',
headers: {
   'Accept': 'application/json',
   'Content-Type': 'application/json',
    },
body: JSON.stringify(myData);

...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.