How would I get just the `results` from

How would I get just the results from the return Response.json(results) area? I'm getting this:
{"success":true,"meta":{"served_by":"v3-prod","duration":0.1977,"changes":0,"last_row_id":0,"changed_db":false,"size_after":16384,"rows_read":1,"rows_written":0},"results":[{"test":"a"}]}
{"success":true,"meta":{"served_by":"v3-prod","duration":0.1977,"changes":0,"last_row_id":0,"changed_db":false,"size_after":16384,"rows_read":1,"rows_written":0},"results":[{"test":"a"}]}
3 Replies
Jun
Jun2w ago
Hey! Like @lambrospetrou pointed out, the response is an object, so you can try resonse.results if you're using JS. I had a quick go on ChatGPT, maybe this will work?
results_array = response["results"]
print(results_array)
results_array = response["results"]
print(results_array)
Full code:
response = {
"success": True,
"meta": {
"served_by": "v3-prod",
"duration": 0.1977,
"changes": 0,
"last_row_id": 0,
"changed_db": False,
"size_after": 16384,
"rows_read": 1,
"rows_written": 0
},
"results": [
{"test": "a"}
]
}

# Extract the "results" array
results_array = response["results"]
print(results_array)
response = {
"success": True,
"meta": {
"served_by": "v3-prod",
"duration": 0.1977,
"changes": 0,
"last_row_id": 0,
"changed_db": False,
"size_after": 16384,
"rows_read": 1,
"rows_written": 0
},
"results": [
{"test": "a"}
]
}

# Extract the "results" array
results_array = response["results"]
print(results_array)
[{'test': 'a'}]
[{'test': 'a'}]
Jun
Jun2w ago
Cloudflare Docs
Return objects · Cloudflare D1 docs
Some D1 Worker Binding APIs return a typed object.
Someone
SomeoneOP2w ago
response["results"] behaves the same as response.get("results") it might be possible that response.results works though i'll give that a try. thanks!
Want results from more Discord servers?
Add your server