I am working on a web application in which I make an API call which returns a response.text() in the form below:
{
"results": [
{
"uuid": "1c661e96-750a-5039-9a7e-676a5b46ad42",
"display": "1004NG - Sarah Gen Mathews",
"links": [{ "rel": "self", "uri": "http://localhost:8080/my-url" }]
}
]
}
I am new to working with APIs so after receiving this, I am not sure how to access the individual parts of this text from my code. For example, I would like to store the uuid
in a variable. This is my fetch()
code section:
fetch(url, requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));
Any help would be greatly appreciated!