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

225
Visualizações
"GET http://localhost:8801/main.js net::ERR_ABORTED 404 (Not Found)" error

Google thinks that I am trying to read data from localhost:8801, but I am trying to read that data from another file called "main.js." The error is "GET http://localhost:8801/main.js net::ERR_ABORTED 404 (Not Found)" How can I reference the command from main.js without google thinking that it is a subdirectory. Here is my code in index.html:

https://sourceb.in/iuMyon5XI7

Thank you in advance.

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

0

I think you are reffering to Chrome browser when you say google (it's confusing) but google have nothing to do with the issue you're facing.
anyway I understand you're trying to get json data from local file; try this

var json = require('./data.json'); //(with your file path)

about 4 years ago · Juan Pablo Isaza Relatório

0

Ok so I was doing some more research over the past few weeks and I realized I was coming about this all wrong. Require is a feature specific to node.js, and because chrome does not just automatically have node.js, it does not work. What I was attempting to do was read a JSON file and output it into some HTML so I can view it there. The solution I found is to get express.js and make an API. So something like

`

app.get("/api/database", (req, res) => {
    res.sendFile(__dirname + '/DB.json')
})

`

And on the HTML side you can add `

fetch('/api/database')
        .then(response => response.json())    
        .then(data => {    
            console.log(data.Input1)
            document.querySelector("#debug").innerText = data.Input1
        })

` With

<div id="debug"></div>

Right above the script tags.

Thanks to everyone who helped. The video I took the html side of the code can be found here.

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