Code Lab

Modo entrevista. Temporizador de 4 min, sin pistas y sin autocompletado

Request method

FácilTypeScript types4 min

Write a function successStatus(method) for API tests. It returns the status code of a successful response. For 'GET' it is 200, for 'POST' 201, for 'DELETE' 204.

The parameter method accepts only these three strings, any other string must be a type error. Do not change the code at the bottom, each line after @ts-expect-error must stay a type error.

Ejemplos

successStatus('GET')

Devuelve 200

A successful GET answers 200.
successStatus('POST')

Devuelve 201

A successful POST creates a record and answers 201.
successStatus('DELETE')

Devuelve 204

A successful DELETE answers 204 with no body.

Fuente

Función
Cargando el editor…
  1. EntradasuccessStatus('GET')
    Esperado200
  2. EntradasuccessStatus('POST')
    Esperado201

Las pruebas ocultas se ejecutan al enviar