Hello amazing Stackoverflow community! I need your help to figure out how to extract data from a weather REST API using JavaScript. I'm struggling to fetch the weather condition and date/time information from this API.
{
info: {
_postman_id: "3683bf65-703d-2798-6901-c97ed650c68f",
name: "IOT",
schema: "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
item: [
{
name: "Find",
id: "df046832-3c4d-950c-ae9f-dae36af7ebc7",
request: {
method: "POST",
header: [
{
key: "Content-Type",
value: "application/x-www-form-urlencoded"
}
],
body: {
mode: "urlencoded",
urlencoded: [
{
key: "table",
value: "data",
type: "text"
},
{
key: "search",
value: "{"device":"24: 6f: 28: 7a: 87: c2","date":{"$gt":"time(2021 - 02 - 21T13: 10: 48.593Z)","$lt":"time(2021 - 02 - 21T14: 10: 48.593Z)"}}",
type: "text"
},
{
key: "",
value: "{"device":"24: 6f: 28: 7a: 87: c2","date":{"$lt":"time(Sun Feb 21 2021 16: 59: 53 GMT + 0300(Arabian Standard Time))"}}",
type: "text"
}
]
},
url: "http://185.247.117.33/DB/Find"
},
response: []
}
]
}
This is my code for fetching data from the API:
fetch('https://www.postman.com/collections/3175ec392efd66dc9a50')
.then(response => response.json())
.then(data => {
console.log(data.item[0].request.body.urlencoded[1].value)
console.log(data.item[0].request.body.urlencoded[2].value) // Prints result from `response.json()` in getRequest
})
.catch(error => console.error(error))
Please, can anyone help me with extracting the array of time and weather conditions?