0

I build my angularjs app with Grunt and yeoman.

My host in example.com and my api is example.com/api

Then I try to use $http like:

$http.get('/api/posts').success(function (data) {
    console.log(data)    //the data is my index.html code
})

Can anyone tell me why the data I get is my index.html code ? And How can I fix it ?

Thanks!

1 Answer 1

2

You get the index.html code back when you try to access the page ('/api/posts') that does not exist or cannot be accessed directly, try seeing

example.com/api/posts/

on browser address bar and see what it returns.

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

2 Comments

Is this related to $routeProvider configure? I have set otherwise({ redirectTo: '/' })
Yes probably this may be the possible cause.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.