4. El servicio devuelve la response, que es recibida en el cliente

index.html

const respuesta = await consume(
 recibeJson("api/devuelve.php"))
const json =
 await respuesta.json()
alert(
 `Mensaje: ${json.mensaje}
Nombre: ${json.nombre}`)

Despierta y recibe response.

Response

HTTP/1.1 200 OK Server: openresty
Date: Sun, 17 May 2026 19:17:52 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Cache-Control: max-age=0
Expires: Sun, 17 May 2026 19:17:52 GMT
{"nombre":"pp","mensaje":"Hola."}

Memoria

respuesta
status
200
body
{"nombre":"pp","mensaje":"Hola."}
json
nombre
"pp"
mensaje
"Hola."

api/devuelve.php

devuelveJson([
 "nombre" => "pp",
 "mensaje" => "Hola."
]);

Devuelve response y se duerme.

skip_previous skip_next