I am diving into the world of AngularJs and have developed a basic factory using $http get to fetch a .json file containing various HTTP status code numbers as keys, paired with their respective messages. However, I keep encountering the following error:
Cannot read property 'get' of undefined
JSON Data:
{
"200": "Ok",
"201": "Created",
"202": "Accepted",
"404": "Not_Found",
"400": "Bad Request",
"403": "Forbidden",
"417": "Expectation Failed"
}
factory.js:
.factory('statusCodesFactory', function () {
var httpStatusCodes = {
getStatus: function ($http) {
$http.get('catalog/statusCodes.json')
.then(function (response) {
httpStatusCodes.code = response;
});
}
}
return httpStatusCodes;
})