mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
06b03bbcfe
no issue - Split out 'getPostPage' & rename to fetchData - Split format response methods into own files - Split out handleError - Split out setReqCtx and rename to setRequestIsSecure - Split out theme paths - Refactor tests in index_spec.js to be more robust - Add tests to bring coverage for split file up to 100%
17 lines
529 B
JavaScript
17 lines
529 B
JavaScript
var api = require('../../api');
|
|
|
|
function fetchData(options) {
|
|
return api.settings.read('postsPerPage').then(function then(response) {
|
|
var postPP = response.settings[0],
|
|
postsPerPage = parseInt(postPP.value, 10);
|
|
|
|
// No negative posts per page, must be number
|
|
if (!isNaN(postsPerPage) && postsPerPage > 0) {
|
|
options.limit = postsPerPage;
|
|
}
|
|
options.include = 'author,tags,fields';
|
|
return api.posts.browse(options);
|
|
});
|
|
}
|
|
|
|
module.exports = fetchData;
|