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

168
Visualizações
save link content on variable

I want to get object from this link:
http://api.weatherapi.com/v1/current.json?key=281c886ff27d4f7cb57182453221607&q=Tehran&aqi=no
I wanna save it on variable.

I wanna do it all on javascript (frond-end). I don't want Node.js Code.
for example save it like this:

const my_weather = {
location: {
...
},
...
};

i wanna use it on my html page

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

JavaScript

The Fetch API provides a JavaScript interface for accessing and manipulating parts of the HTTP pipeline

const url = 'http://api.weatherapi.com/v1/current.json?key=281c886ff27d4f7cb57182453221607&q=Tehran&aqi=no';

fetch(url)
  .then((response) => {
    console.log(response);
  });

jQuery

If jquery is allowed, you can use getJSON to do it

const url = 'http://api.weatherapi.com/v1/current.json?key=281c886ff27d4f7cb57182453221607&q=Tehran&aqi=no';

$.getJSON(url, response => {
  console.log(response);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

about 4 years ago · Santiago Gelvez Relatório
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