0

I am trying to include a json file with data, in a mean stack app running locally.

I have tried these methods, and I am still getting a 404 error

$http.get('MOCK_DATA.json').success(function (res){
    $scope.Alldata = res.data;
    $scope.$apply;

});
var getPromise = $http.get('MOCK_DATA.json').then(function(response){ 
  //whatever is returned here will be accessible in the .then that is chained
  return response.data;
});    

console.log(getPromise);

$http({
  method: 'get',
  url: 'MOCK_DATA.json'
}).then(function (response){
  $scope.Alldata = response;
},function (error){

});
1

1 Answer 1

0

Just need to import json file from correct file and you will get access of it like var data = require('./data.json');

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.