Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

318
Visualizações
¿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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda