Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

I using list from json on my page. I work on localhost, then push to server. Elemets tree looks like:

/
|--> about/
|         |--> about.html
|         |--> about.js
|         |--> list.json // first try
|--> smth/
|--> components/
|--> index.html
|--> style.sass
|--> list.json

I'm not able to reach the list.json file.

I tried using both ./about/list.json and about/list.json, having list.json file in the about directory.

Then I tried with list.json in the root, I used list.json.

So I have 2 different errors:

When list.json is in about/ dir - on localhost it works fine, but on server I have 404 Error. This is the code I use:

$http.get('./app/list.json').then(function (res) {
  var goods = res.data;
};

When list.json is in root dir the server returns index.html page..

$http.get('list.json').then(function (res) {
  var goods = res.data;
};

What's wrong?

share|improve this question
    
The problem seems on the webserver - which webserver do you use? How did you configure it? – rpadovani Aug 7 at 15:17
    
@rpadovani It's a big project and I'm front-end dev so unfortunately I don't know about server a lot.. – YoroDiallo Aug 7 at 15:21
    
@rpadovani but when I make link to sass or pics or for scripts - all dir links is working. or It's a problem just with a $http.get? – YoroDiallo Aug 7 at 15:23
1  
Maybe the server isn't configured to serve the .json file. What happens if you try to reach it from the browser? – rpadovani Aug 7 at 15:24
1  
The best thing to do is to inform who manage the server that is impossible to reach .json files – rpadovani Aug 7 at 15:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.