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

313
Vistas
¿Tomar una variable de una solicitud HTTPGET y crear una función de declaración if?

Lo siento si esto está mal publicado, soy nuevo en todo esto.

Tengo una API meteorológica que proporciona las condiciones climáticas en la variable llamada condiciones. Me gustaría tomar esa variable y hacer una función de instrucción if con ella como parámetro. Luego estableceré la variable weather_genre para la segunda API para esta función ("Horror" es un marcador de posición).

// ubicación obtener api $.getJSON("https://ipgeolocation.abstractapi.com/v1/?api_key=41b35af8793c40819cf4cf013b54802c", función(datos) { console.log(datos); var longlat = datos["longitud"]+ ","+ datos["latitud"];

 // weather get api (long,lat) $.getJSON("https://devapi.qweather.com/v7/weather/now?unit=i&lang=en&key=86a7ff0e360e463db560e321bd071d25",{"location" : longlat}, function(data){ console.log(data); var conditions = data["now"]["text"]; //$('#weather').html(conditions); }); }) //anime post api var weather_genre = "Horror"; // Here we define our query as a multi-line string // Storing it in a separate .graphql/.gql file is also possible var query = ` query ($genre: String) { # Define which variables will be used in the query (id) Media (type: ANIME, genre: $genre) { # Insert our variables into the query arguments (id) (type: ANIME is hard-coded in the query) id title { english } } } `; // Define our query variables and values that will be used in the query request var variables = { genre: weather_genre }; // Define the config we'll need for our Api request var url = 'https://graphql.anilist.co', options = { method: 'POST', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', }, body: JSON.stringify({ query: query, variables: variables }) }; // Make the HTTP Api request fetch(url, options).then(handleResponse) .then(handleData) .catch(handleError); function handleResponse(response) { return response.json().then(function (json) { return response.ok ? json : Promise.reject(json); }); } function handleData(data) { console.log(data); } function handleError(error) { alert('Error, check console'); console.error(error); }
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