Search code examples
javascriptjsonangularjsfeed

How to get MIXED FORMAT with google feed API using AngularJS


Im using the google's feed API with AngularJS and I need to get my feed data in a mixed format (json & xml). I'm using the following code to call the Google's Api throught ngResurce, I'd been trying change the method and callback tags to MIXED_FORMAT but I couldn't make it works. Here Google explains how to use it, but I have no idea about how to apply it to AngularJS https://developers.google.com/feed/v1/devguide#resultMixed

.factory('FeedLoader', function ($resource) {
    return $resource('http://ajax.googleapis.com/ajax/services/feed/load', {}, {
        fetch: { method: 'JSONP', params: {v: '1.0', callback: 'JSON_CALLBACK'} }
    });
})

Solution

  • You can simply add it to the params in your query. I modified your example to set the output format to mixed mode.

    .factory('FeedLoader', function ($resource) {
        return $resource('http://ajax.googleapis.com/ajax/services/feed/load', {}, {
            fetch: { method: 'JSONP', params: {v: '1.0', callback: 'JSON_CALLBACK', output: 'json_xml'} }
        });
    })