Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

123
Vistas
How can I create a fetch url with optional input fields within a web application

I am making an API call by using fetch method(GET) of Jquery. My question is, how can include empty input fields (totally optional, user may fill those areas, maybe not) into my fetch url. When I tried to send them as empty string, server is responding with a status code(400)- bad request.

These are the optional input fields to fill enter image description here

MY JAVASCRIPT CODE

var fetchUrl = "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode="
+iataOrigin+"&destinationLocationCode="
+iataDestination+"&departureDate="
+getFlightDepartureDate()+"&adults="
+getFlightAdults()+"&max="+getmaxTicket()

console.log(fetchUrl)

const settings = {
    "url": fetchUrl,
    "method": "GET",
    "headers": {
        
            "Authorization" : "Bearer myTokenInHere"

    }
};

$.ajax(settings).done(function (response) {
    console.log(response);
});

For instance, I want to declare a URL such as 'adult number input field value' is not initialized, it's an empty string. Like this :

"&adults="

After trying this, server is not responding with a status code 200. I would be very thankful for your help.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda