11. js / lib / recibeTexto.js

1
/**
2
 * @param {FormData} formData
3
 * @param {string} parametro
4
 */
5
export function recibeTexto(formData, parametro) {
6
 const valor = formData.get(parametro)
7
 if (valor !== null && typeof valor !== "string")
8
  throw new Error(`El valor de ${parametro} debe ser texto.`)
9
 return valor === null ? undefined : valor
10
}
11
skip_previous skip_next