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

252
Views
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
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!