Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

371
Vistas
Uncaught TypeError: x is not a function when Importing Factory Function

I have a factory function called updateUI which I am importing into index.js. When imported, the instance of updateUI is recognized, however I am given an error when attempting to call updateUI's methods.

Putting all of the code into index.js gets rid of the bug, but it still has me scratching my head. It seems the problem occurs only when importing. Why are the method's not being recognized?

index.js

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

display.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 };

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Question answered by @code in the comments.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda