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

191
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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