Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

241
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!