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

258
Vistas
Importing Data from a JS file into Svelte

I'm new to Svelte and I'm trying to import an object I have in a separate JS file into my App.svelte file to be used. When I try and import the data, I get the whole function instead of the return value when I try and console log it or it return object Object. For simplicity sake, I just made date.js file that returns the date and I've tried the 2 export method up top, neither have worked.

date.js

module.exports = getDate
function getDate(){
  date = Date()
  return date;
}

In the App.svelte file I have:

<script>
    import { getDate } from './date.js'
    let date = getDate()
</script>

I noticed that in my node/express app, the return type of getDate is an Object and in the Svelte app the return type is a Number and I'm not sure why this is. Also the date.js file is location in the src folder so that isn't an issue. Any help would be appreciated! Thanks

about 4 years ago · Juan Pablo Isaza
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