ACTIBIOS DISTRIBUCIONS
business mié, 22 mar 2023 10:58:11

ACTIBIOS DISTRIBUCIONS

Sure, I can help you with that!

In JavaScript, you can make an HTTP request using the built-in XMLHttpRequest object or the newer fetch() API.

Here's an example of using XMLHttpRequest to make a GET request:

This code creates a new XMLHttpRequest object and uses its open() method to specify the HTTP method (GET) and the URL to make the request to. It then sets a callback function to be called when the request completes, using the onload property. If the response status code is 200 (OK), it logs the response text to the console. Otherwise, it logs an error message with the status code.

Here's an example of using fetch() to make the same GET request:

This code calls the fetch() function with the URL to make the request to. It then returns the response text if the response status is OK, using the text() method. If the response status is not OK, it throws an error with the status code. It then logs the response data to the console using another then() callback, or logs the error if the request fails.

Note that fetch() returns a Promise, which allows for more concise and readable code when working with asynchronous requests.

I hope that helps! Let me know if you have any other questions.

avatar Juan carlos Gracia Carrillo Juan carlos Gracia Carrillo
0

0 Comentarios

Deja un comentario

Relacionadas

VALORACIONES MEDITERRANEO
business dom, 24 mar 2024 10:19:28
VALORACIONES MEDITERRANEO
EUROBANAN LOGISTICA NORTE
business dom, 02 jul 2023 08:11:25
EUROBANAN LOGISTICA NORTE
HERMES COMUNICACIONS
business mar, 05 dic 2023 08:52:10
HERMES COMUNICACIONS
MARTINEZ Y CANTO
business dom, 17 sep 2023 07:33:39
MARTINEZ Y CANTO
DELGO OPERADOR DE TRANSPORTE
business sáb, 29 abr 2023 07:20:46
DELGO OPERADOR DE TRANSPORTE

© Sólo Útil. Todos los derechos reservados. Design by HTML Codex