I'm trying to get the alert ID and name records from the database using Javasript fetch API.
My problem is that since the alerts are empty, there aren't any alerts.
I think there is something wrong with this line of code
1 |
|
. This is an example of json returned by the database
1 |
|
This is the fetch API Javascript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
This is the php code
1 2 3 4 5 6 7 8 9 10 11 |
|
P粉4788355922024-04-04 11:28:02
Adding return to the line of code here also solved the problem. Finally, I also made sure there were no whitespace in the code.
1 |
|
P粉4662901332024-04-04 09:31:10
The above syntax is not quite correct. You link .next()
directly to response.json()
- i.e. response.json().then(
, where it should be more like below (slightly abbreviated), where .next()
is bound to the entire previous next()
part
1 2 3 4 5 6 7 |
|