简体   繁体   中英

How can I get the same content in my react native app as in my postman GET?

I'm communicating with a REST server, which should return ( and this is what I get when I use Postman to request it):

    {
        "organizer": "Fontysgroup2",
        "eventStart": "2019-11-25T11:00:00Z",
        "eventStop": "2019-11-25T11:00:00Z",
        "room": {
            "roomName": "Test Room",
            "roomEmail": null,
            "password": null
        }
    },
    {
        "organizer": "Fontysgroup2",
        "eventStart": "2019-11-25T11:00:00Z",
        "eventStop": "2019-11-25T11:00:00Z",
        "room": {
            "roomName": "Test Room",
            "roomEmail": null,
            "password": null
        }
    }
]

but this block of code of mine :


  await fetch('https://gitroom-backend.azurewebsites.net/api/Event', {
    headers: {
      Authorization: 'Bearer eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIs',
    }

  })
  .then(res => {
    console.log("content"+JSON.stringify(res))
  })
}

is returning:


content{"type":"default","status":200,"ok":true,"headers":{"map":{"cache-control":"public, max-age=0","date":"Mon, 25 Nov 2019 13:14:09 GMT","set-cookie":"ARRAffinity=84e8f0e39af3bde1a8c7117e525b046a8722dc904bb8684ace19b555cc8f3590;Path=/;HttpOnly;Domain=gitroom-backend.azurewebsites.net","x-powered-by":"ASP.NET","request-context":"appId=cid-v1:65c12a05-4adc-4521-b71d-69ccdcb78d9f","server":"Microsoft-IIS/10.0","vary":"Accept-Encoding","content-type":"application/json; charset=utf-8","transfer-encoding":"chunked"}},"url":"https://gitroom-backend.azurewebsites.net/api/Event","_bodyInit":{"_data":{"size":331,"offset":0,"blobId":"7592c623-fb09-415e-92f7-a97e75b08d37"}},"_bodyBlob":{"_data":{"size":331,"offset":0,"blobId":"7592c623-fb09-415e-92f7-a97e75b08d37"}}}

How can I access the actual content that I want and which Postman is giving me?

EDIT:

MY Postman: 在此处输入图片说明

fetchData = async () => {
      const response = await fetch(
        "YOUR_URL"
      );
        const json = await response.json();

} 

Now render items iterative using constructor of your data set. and call in your view by,

{item.YOUR_KEY}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM