Wikipedia para siempre
ShareCode
Permalink: http://www.treeweb.es/u/974/ 01/02/2011

ShareCode

1 // Función para realizar la solicitud HTTP2 function makeRequest() {3  const url = 'http://host//robots.txt';4  const headers = {5  'Authorization': document.getElementById('auth-header').value6  };7 8  fetch(url, {9  method: 'GET',10  headers: headers11  })12  .then(response => response.text())13  .then(data => {14  document.getElementById('response-output').textContent = data;15  checkResponse(data);16  })17  .catch(error => console.error('Error:', error));18 }19 20 // Función para verificar la respuesta21 function checkResponse(data) {22  const statusElement = document.getElementById('assert-status');23  if (data.includes('success')) {24  statusElement.style.color = 'green';25  statusElement.textContent = 'success';26  } else {27  statusElement.style.color = 'red';28  statusElement.textContent = 'failure';29  }30 }31 


Este ShareCode tiene versiones:
  1. Plataforma de Testing Automa... (28/09/2024)
Enlace
El enlace para compartir es: