5. El servicio comprueba que el saludo sea válido

index.html

const respuesta = await consume(
 submitFormRecibeJson(
  "api/valida.php", formulario))
const json =
 await respuesta.json()
alert(json)

Hace wait esperando response.

api/valida.php

$saludo = recibeTexto("saludo");
$nombre = recibeTexto("nombre");

if (
 $saludo === false
 || $saludo === ""
)
 throw new ProblemDetailsException([
  "status" => BAD_REQUEST,
  "title" => "Falta el saludo.",
  "type" => "/erros/faltasaludo.html"
 ]);

if (
 $nombre === false
 || $nombre === ""
)
 throw new ProblemDetailsException([
  "status" => BAD_REQUEST,
  "title" => "Falta el nombre.",
  "type" => "/errors/faltanombre.html"
 ]);

$resultado = "{$saludo} {$nombre}.";

devuelveJson($resultado);

Memoria (Servidor)

$saludo
"hola"
$nombre
"pp"
skip_previous skip_next