• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

256
Views
TypeError no detectado: x no es una función al importar la función de fábrica

Tengo una función de fábrica llamada updateUI que estoy importando a index.js. Cuando se importa, se reconoce la instancia de updateUI; sin embargo, recibo un error al intentar llamar a los métodos de updateUI.

Poner todo el código en index.js elimina el error, pero todavía me tiene rascándome la cabeza. Parece que el problema ocurre solo al importar. ¿Por qué no se reconoce el método?

índice.js

 import '../../dist/output.css'; import { updateUI } from './display.js'; const test = updateUI('Daly City'); test.setBackground();

pantalla.js

 import { getWeather } from './apiCall'; const updateUI = async(location) => { const res = await getWeather(location, process.env.apiKEY); function updateCity() { const city = document.querySelector('#location'); city.innerHTML = res.name; }; function updateCurrentTemp() { const currentTemp = document.querySelector('#current-temp'); const farenheit = Math.round((9/5)*(res.main.temp - 273) + 32); currentTemp.innerHTML = farenheit; }; function updateConditions() { const condition = document.querySelector('#weather'); condition.innerHTML = res.weather[0].description; }; function setBackground() { const date = new Date(); let time = date.getTime(); console.log(time); }; return { updateCity, updateCurrentTemp, updateConditions, setBackground } }; export { updateUI };
almost 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Pregunta respondida por @code en los comentarios.

almost 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error