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

254
Visualizações
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 à 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