Reputation: 1450
i have a Rails API
Ex. example.com/v1/portfolio/{{ id }}
and i'm using AngularJS ngResource to handle the data with get.
myAppServices.factory('Portfolio', ['$resource', function($resource){
return $resource('api/v1/portfolios/:id/', { id:'@id'}, {
query: {
method:'GET',
params:{id:'@id'},
isArray:true
}
});
}]);
How can i handle the Not found 404 Error if the API does not have an Entry
Ex. example.com/v1/portfolio/blabla
i mean how can i make it 404 like when u enter http://www.google.com/sdfa check the network status code you'll find it 404.
For more information am using Prerender.io service to Render the website for Search Engines.
Upvotes: 0
Views: 1150
Reputation: 1604
You should use the prerender-status-code meta tag to return a 404 to the crawler. The documentation is here: https://prerender.io/documentation/best-practices
Basically, just add to the of the page if the page should return a 404 to crawlers. Prerender.io will detect that status code and return that to the crawler instead of a 200.
Feel free to send an email to [email protected] if you have any other questions about that. We're happy to help!
Upvotes: 1
Reputation: 13753
You can use $promise like this:
var resource = $resource('api/v1/portfolios/:id/');
resource.get({id: 123}).$promise.then(function(todo) {
// success
}, function(errResponse) {
// handle 404 here
});
Upvotes: 2