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

205
Visualizações
Load a file from localSystem with javascript without a server

I make an app with javascript, I need to work with no any server in the local network. Only chrome browser run from /Services/ServiceFinder/index.html.

When load index.html need to read a XLSX file from the same directory as a file(i use the SheetJS library to read XLSX as a db and convert it to a javascript object).

I use fetch after window load event but i take an error message "The file is not loaded successfully."

window.addEventListener('load', (event) => {

//Get the file input
var file = "./ServicesData.XLSX";

//Load file
fetch(file, {mode: "no-cors"}).then(response => {

    if(response.ok) {
        console.log("%cThe file is loaded successfully.", styleConsoleLog);
    }else{
        console.error("The file is not loaded successfully.");
    };
    return response.arrayBuffer();

}).then(arrayBuffer => {

The same code is working perfectly when i use the server.

run only from chrome

run with a server

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can simply create a http server on the local network and serve the file there with NodeJS.

/* ====== create node.js server with core 'http' module ====== */
// dependencies
const http = require("http");

// PORT
const PORT = 3000;

// server create
const server = http.createServer((req, res) => {
   if (req.url === "/") {
      res.write("This is home page.");
      res.end();
   } else if (req.url === "/about" && req.method === "GET") {
      res.write("This is about page.");
      res.end();
   } else {
      res.write("Not Found!");
      res.end();
   }
});

// server listen port
server.listen(PORT);

console.log(`Server is running on PORT: ${PORT}`);

// ======== Instructions ========
// save this as index.js
// you have to download and install node.js on your machine
// open terminal or command prompt
// type node index.js
// find your server at http://your.network.ip.address:port/

learn about it here: How could others, on a local network, access my NodeJS app while it's running on my machine?

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