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

190
Vistas
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 Respuestas
Responde la pregunta

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 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