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

198
Views
How can I import a data file as a variable?

I have a somewhat non-standard need where I need to store a large blob of data in a text file, and import it into svelte. Currently, my object looks like this

<script>
let data = "A very large string";
</string>

<div>
{data}
</div>

I want to store the contents of data as a string, which is dynamically compiled into the object, e.g.

<script>
let data = import("myData.txt");
</string>

<div>
{data}
</div>

I Can't see anything in the svelte documentation that says this is supported, but I'm new to svelte / front-end dev, so maybe someone can suggest a workaround?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Store the large blob of data inside a .txt file on the server at a location where it can be publicly accessed, and then use fetch() to load it from there.

let data = await fetch('https://localhost/public_path/myData.txt')
  .then(res => res.text());

Note: I have no experience with svelte

All the best.

about 4 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 Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!