Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I'm trying to follow along a AngularJS tutorial about making a Email Client.

I downloaded the source code with all chapters from 01 to 07. Started my own project in a folder called "Application".

Project Folder

The code is running without throwing any errors, but the thing is that it's the wrong JSON file that is being loaded!

I copied the json from 04 and changed the first from to be Hello World (originally TicketFactory). Changed every others json files to contain their location, so chapter 04 became TicketFactory chapter 04 and so on.

Now starting the server in the Application directory gives me this:

Console

browser result

I have no clue where it is getting this .json file..? Perhaps an old GET request?

My code looks like this

InboxFactory.js

(function() {
  'use strict';

  angular
    .module('EmailApp')
    .factory('InboxFactory', myfactory);

  myfactory.$inject = ['$q','$http', '$location'];

  function myfactory($q, $http, $location){
    var exports = {};

    exports.getMessages = function () {
      return $http.get('json/emails.json')
        .error(function(data) {
          console.log('There was an error!', data);
        });
    };

    return exports;
  }

})();

It might look a bit different from the tutorial because I used Atom's AngularJS snippet package. But it looks good enough for me, but then again - I'm still learning!

share|improve this question
    
I found the emails.json under Network and saw that it got it from cache. I then cleared the browser cache and it worked. – Norfeldt 18 hours ago
up vote 1 down vote accepted

It also could be a cache problem !

Do F12, and check the "Network" tabs (with an F5...): you will retry the full path of the file, it's contents,...

share|improve this answer
    
I have tried to refresh it a couple of times and no luck. – Norfeldt 18 hours ago
    
Have you checked the path displayed in the "referer" field , in the "Network" tabs ? – Didier68 18 hours ago
    
arhh sorry I misunderstoood you. – Norfeldt 18 hours ago
    
It doesn't seem useful to me to use cache when the content in the cache is outdated... or am I missing something? – Norfeldt 18 hours ago
    
Yes, of course, but it's your web browser which manages the cache and decides to read or not on the server. In general, if the URL does not change (file name or identical parameter), the browser can assume that the file has not changed on the server and not read it again ... One method to force the reload of the json file would be to add a timestamp parameter : return $http.get('json/emails.json?d=160206203051') – Didier68 17 hours ago
return $http.get('json/emails.json')

This is misleading because you have multiple json folders containing emails.json on your project root.

Try : return $http.get('../Application/json/emails.json')

share|improve this answer
    
That didn't work.. gave an error 404 in the console - File not found. The header My Inbox loaded just fine.. – Norfeldt 18 hours ago
    
What was error log on the console ? where did it tried to fetch the json ? – Jorel Loki Amthor 17 hours ago

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.