export function requestSitePosts( siteId, query = {} ) {
return ( dispatch ) => {
dispatch( {
type: POSTS_REQUEST,
siteId,
query
} );
return wpcom.site( siteId ).postsList( query ).then( ( { found, posts } ) => {
dispatch( receivePosts( posts ) );
dispatch( {
type: POSTS_REQUEST_SUCCESS,
siteId,
query,
found,
posts
} );
} ).catch( ( error ) => {
dispatch( {
type: POSTS_REQUEST_FAILURE,
siteId,
query,
error
} );
} );
};
}