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

234
Visualizações
Still getting a double click error even though the flow is right
let fieldName   = ""
let jsonResponse = ""
let collectionName = ""
let fieldEl     = document.getElementById("field_el")
let inputEl     = document.getElementById("input-el")
let buttonEl    = document.getElementById("button-el")

let collectionData = {
    averagePrice: ""
}
    
const getStatsAvgPrice = {
    currentAP: function() {
        collectionData.averagePrice = jsonResponse.stats["average_price"]
    }
}

function callApi(collectionName,fieldName) {
    fetch(`https://api.opensea.io/api/v1/collection/${collectionName}/${fieldName}`)
    .then(response => response.json())
    .then(response => jsonResponse = response)
    .then(getStatsAvgPrice.currentAP())
    .then(render())
    .catch(err => console.error(err));
}

function render() {
    document.getElementById("report").innerHTML = JSON.stringify(collectionData.averagePrice);
    console.log(JSON.stringify(collectionData.averagePrice))
}

buttonEl.addEventListener("click", () => {
    collectionName  = inputEl.value
    fieldName       = fieldEl.value
    callApi(collectionName,fieldName)
}) 

How can I get this to work? Perhaps make more functions? Add to the dom? Any ideas would be helpful. Still getting a double click error even though the flow is right.

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