Solicitud POST con Fetch API?
Sé que con la nueva API Fetch (utilizada aquí con ES2017'sasync
/await
) puede hacer una solicitud GET como esta:
async getData() {
try {
let response = await fetch('https://example.com/api');
let responseJson = await response.json();
console.log(responseJson);
} catch(error) {
console.error(error);
}
}
Pero, ¿cómo hacer una solicitud POST?