// Fetches a page of starred repos by a particular user. // Relies on the custom API middleware defined in ../middleware/api.js. function fetchStarred(login, nextPageUrl) { return { login, [CALL_API]: { types: [ STARRED_REQUEST, STARRED_SUCCESS, STARRED_FAILURE ], endpoint: nextPageUrl, schema: Schemas.REPO_ARRAY } } }
// Fetches a page of stargazers for a particular repo. // Relies on the custom API middleware defined in ../middleware/api.js. function fetchStargazers(fullName, nextPageUrl) { return { fullName, [CALL_API]: { types: [ STARGAZERS_REQUEST, STARGAZERS_SUCCESS, STARGAZERS_FAILURE ], endpoint: nextPageUrl, schema: Schemas.USER_ARRAY } } }
function fetchPosts(nextPage) { return { [CALL_API]: { types: [ POSTS_REQUEST, { type: POSTS_SUCCESS, payload: (action, state, res) => { return res.json().then((json) => normalize(json, { posts: Schemas.POST_ARRAY })) } }, POSTS_FAILURE ], method: 'GET', endpoint: `http://localhost:3000/api/post?page=${nextPage}`, } } }
function fetchItems(nextPage) { return { [CALL_API]: { types: [ ITEMS_REQUEST, { type: ITEMS_SUCCESS, payload: (action, state, res) => { return res.json().then((json) => normalize(json, {items: Schemas.ITEMS_ARRAY})) } }, ITEMS_FAILURE ], method: 'GET', endpoint: `http://localhost:3000/api/item?page=${nextPage}`, } } }
// Fetches a page of starred repos by a particular user. // Relies on the custom API middleware defined in ../middleware/api.js. const fetchStarred = (login, nextPageUrl) => ({ login, [CALL_API]: { types: [ STARRED_REQUEST, STARRED_SUCCESS, STARRED_FAILURE ], endpoint: nextPageUrl, schema: Schemas.REPO_ARRAY } })
// Fetches a page of stargazers for a particular repo. // Relies on the custom API middleware defined in ../middleware/api.js. const fetchStargazers = (fullName, nextPageUrl) => ({ fullName, [CALL_API]: { types: [ STARGAZERS_REQUEST, STARGAZERS_SUCCESS, STARGAZERS_FAILURE ], endpoint: nextPageUrl, schema: Schemas.USER_ARRAY } })