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

276
Visualizações
Error: Uncaught (in promise): Response with status: 404 Not Found for URL when upgrading to Angular-CLI + Angular 4

I updated my project and everything was fine in Angular 2 and now 4. I now brought in Angular-CLI 1.0.0 and it will not find the json file for primeNG.

 constructor(private http: Http) {}

    getFiles() {
        return this.http.get('mock_data/data.json')
            .toPromise()
            .then(res => <TreeNode[]> res.json().data)
            .then(data => { return data; });
    }

Is throwing the error and I tried adding a ./ copied the path of the folder to double check.

In my index.html file I have <base href="/"> and the directory is under src

Error:

core.es5.js:1084 ERROR Error: Uncaught (in promise): Response with status: 404 Not Found for URL: http://localhost:4200/mock_data/data.json

enter image description here

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Try moving mock_data into the assets folder and then update the url with 'assets/mock_data/data.json'.


Suggested edit:

Another way : only add "mock-data" into .angular-cli.json file:

"assets": [
            "assets",
            "favicon.ico",
            "mock-data"
        ]
over 4 years ago · Santiago Trujillo 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