Introducción a JavaScript

1

¿Por qué aprender JavaScript?

2

¡Hola Mundo! en Mac

3

¡Hola Mundo! en Windows

4

Anatomía de una variable

5

Tipos de datos en JavaScript

6

Creación de strings

7

Operadores aritméticos

8

Conversión de tipos: Type Casting y Coerción

9

Conversión de tipos explícita e implícita

Estructuras de Control y Lógica

10

Operadores de comparación

11

Operadores lógicos

12

Ejecución condicional: if

13

Ejercicio: Adivina el número

14

Ejecución condicional: switch

15

Loop: for

16

Loop: for of

17

Loop: for in

18

Loop: while

19

Loop: do while

Funciones y This

20

Anatomía de una función

21

Funciones vs Métodos

22

Funciones puras e impuras

23

Arrow function y enlace léxico

24

Contextos de ejecución y scope chain

25

¿Qué es Closure?

26

Preguntas a Desarrolladores Senior: ¿Por qué aprender Desarrollo Web?

Manipulación de Arrays

27

Introducción a Arrays

28

Mutabilidad e inmutabilidad de Arrays

29

Modificación básica del final con push( ), pop( )

30

Iteración con map( ) y forEach( )

31

Filtrado y reducción con filter( ) y reduce( )

32

Búsqueda de elementos con find( ) y findIndex( )

33

Crear copias con slice( )

34

Spread operator: casos de uso

Programación Orientada a Objetos

35

Anatomía de un Objeto

36

Trabajando con objetos en JavaScript

37

Función constructora

38

¿Qué es una clase?

39

Prototipos y herencias

40

Herencia en la práctica

41

Prototipos en la práctica

42

this en JavaScript

43

Proyecto: Crea una red social

44

Proyecto: Crea una red social parte 2

Asincronía en JavaScript

45

¿Cómo funciona el JavaScript Engine?

46

Promesas en JavaScript

47

Usando Async y await en JavaScript

48

For await of

49

¿Cómo funciona la web?

50

¿Cómo funciona HTTP?

51

Método GET en JavaScript

52

Método POST en JavaScript

53

Método DELETE en JavaScript

54

Importancia del id en el método DELETE

55

ECMAScript 6 y tus siguientes pasos

You don't have access to this class

Keep learning! Join and start boosting your career

Aprovecha el precio especial y haz tu profesión a prueba de IA

Antes: $249

Currency
$209
Suscríbete

Termina en:

0 Días
2 Hrs
50 Min
26 Seg

¿Cómo funciona HTTP?

50/55
Resources

What is HTTP and how do we use it on the front-end?

When developing web applications, understanding how to handle HTTP requests is fundamental for communication between the front-end and the servers. HTTP (Hypertext Transfer Protocol) is the protocol for making data requests and sending information between clients and servers. In practice, HTTP methods are used using the fetch function in JavaScript to interact with APIs.

How do fetch requests work?

When we use fetch, we are requesting a server to provide us with information that we can then handle and display in the DOM. Using fetch, we make a request to an API, which often returns data in JSON format. Using fetch is a way to make HTTP requests asynchronously, which allows us to improve the user experience by loading data without interrupting the flow of the application.

fetch('https://jsonplaceholder.typicode.com/posts').then(response => response.json()).then(data => console.log(data));

This code performs a GET request to an example API that returns dummy information.

What do HTTP status codes mean?

When making HTTP requests, it is crucial to interpret the status codes that accompany them, since they tell us the result of the requested operation:

  • 200 OK: The request was successful.
  • 404 Not Found: The requested resource has not been found.
  • 500 Internal Server Error: An error has occurred on the server.

Knowing these codes helps us to diagnose problems and understand the communication between the client and the server.

How to check requests and responses in the browser?

The browser offers development tools that facilitate the monitoring of HTTP requests. The "Network" tab allows us to observe:

  • The requests to HTML, JavaScript and CSS.
  • The URL to which the request is made.
  • The status of the response obtained, such as a 200 OK.
  • The loading speed of the resources.

By accessing the "Network" tab, we can determine the success of our requests and understand what happens with each request that is made, strengthening our knowledge of data management in web applications.

Practical example of interaction with an API

Let's imagine that we are generating information from an API using fetch. We can drill down and work with the returned information to, for example, obtain user details and display them in our application.

When fetch is executed, the API is queried and, using promises(then), we handle the response. If the request is successful, we get a JSON object with the data:

fetch('https://jsonplaceholder.typicode.com/posts').then(response => response.json()).then(data => { // Data is processed to display titles, users, etc. data.forEach(post => { console.log(post.title); }); });

This basic structure demonstrates how we can extend the functionality of fetch to suit the needs of our application.

Understanding HTTP and fetch gives us control over the front-end interactions with the server, allowing us to optimize the development process and providing a more efficient and dynamic user experience. Keep exploring and experimenting with different scenarios to expand your skills!

Contributions 7

Questions 0

Sort by:

Want to see more contributions, questions and answers from the community?

<https://http.cat/> Pagina para entender los diferentes status
Buenas, no veo en la sección de recursos los archivos de HTML y CSS que el profesor menciona en el vídeo.
con gatos todo se vuelve mil veces mas entretenido jahjhafjh![](https://static.platzi.com/media/user_upload/image-3ef7c5d8-2d87-4eaa-bb67-a91bb3425728.jpg)
¿Como funciona HTTP HTTP funciona de la siguiente manera: 1\. El cliente (navegador web) envía una solicitud HTTP al servidor. 2\. El servidor recibe la solicitud y la procesa. 3\. El servidor devuelve una respuesta HTTP al cliente. 4\. El cliente recibe la respuesta y la procesa. 5\. El cliente muestra la respuesta al usuario.
No es mi intención ser grosero ni nada por el estilo, pero creo que el Profe Diego es muy difícil de entender... creo que necesita estructurar mejor sus ideas.
Mis notas: ![](https://static.platzi.com/media/user_upload/image-ac96102b-15a0-455c-8d0c-77da4976094d.jpg)
## **¿Qué son los HTTP Status Codes?** Son la forma en la que el protocolo http nos dice como va nuestra solicitud, si hubo algún error de nuestra parte o de parte de la base de datos Los status code van del 100 hasta el 500 * Los del 200 significan que tanto frontend como backend estan bien, la solicitud va bien. * Si es un 201 o 202 puede ser que el backend o la API nos este especificando cual fue el tipo de éxito que tuvimos o si aun esta en proceso la solicitud * Los 300 significan redirects, la ruta a la que estamos entrando no es la ruta final sino que el backend hace un redirect hacia alguna otra ruta y simplemente te muestra que la solicitud esta realizada pero no si esta bien o mal * Un 307 significa que el redirect es temporal, no sabemos si en el futuro esa ruta a la que nos esta re dirigiendo será la misma o la cambiaran * Un 308 es el backend indicando que siempre sera esa ruta por la que hará el redirect * Los 400 significan que nosotros nos equivocamos, el frontend hizo una solicitud incorrecta o un typo en sintaxis o en ruta * Un 401 significa que la ruta, el endpoint no funciona tal cual sino que debemos hacer un paso de autenticación y no estamos autorizados para recibir esa información * Un 402 significa que necesitamos pagar para poder entrar y recibir esa información * Un 404 significa que lo que estamos solicitando no existe * Si es 500 significa que no sabemos si el front esta bien pero el backend fallo y existen muchas razones por las que el back falla, podría ser el exceso de solicitudes que no alcanza a cubrir el back y el tiempo de front termina y manda ese error o que muera el back y en caso de que muera, el front no tiene manera de remediarlo.