1

I have a json Output from fetch method, which is something like in this format

{ 
"example": {
"id": "301",
"example_n": "example",
"exampleid": "12",
"thumbnail": "some url",

"examplearry": [
  {
    "example_id": "9",
    "exampletitle": "exampletitle ",

  },
  {
    "example_id": "10",
    "exampletitle": "exampletitle",

  },
  {
    "example_id": "7",
    "exampletitle": "exampletitle",


  }, "example_api": "6vvdncv99hbnbscm" 
}

Now i want to access example_id and exampletitle. How to use it in react native?

1 Answer 1

1

You can see how to do it here.

Implement something like the fetchData method they have:

fetchData() {
    fetch(REQUEST_URL)
    .then((response) => response.json())
    .then((responseData) => {
        this.setState({
          examplearry: responseData.examplearry,
        });
    })
    .done();
}

This will process your json response and then, with this.setState, you can make your data available. After this, just access the examplearry like you would in javascript/react. The tutorial also shows how to do this in detail in the next step.

Sign up to request clarification or add additional context in comments.

2 Comments

yes i was able to do this thing ,but when i started usind data like examplearry.example_n , examplearry.examplearry.example_id.It is giving undefined.How to use this data to display on views
Are you sure you're serializing correctly all the data when creating the JSON? Can you show me how your responseData looks like?

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.