This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { sanitizeEntity } = require('strapi-utils'); | |
| module.exports = { | |
| query: ` | |
| categoryBySlug(slug: String!): Category | |
| `, | |
| resolver: { | |
| Query: { | |
| categoryBySlug: { | |
| resolverOf: 'Category.findOne', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .bg { | |
| 600% 500%/90% 90% radial-gradient(closest-side,rgba(228,79,79,.7),rgba(228,79,79,0)) no-repeat,600% 180%/90% 90% radial-gradient(closest-side,rgba(228,79,79,.7),rgba(228,79,79,0)) no-repeat,100% 150%/75% 50% radial-gradient(closest-side,rgba(250,250,218,.2),rgba(250,250,218,0)) no-repeat,-400% -100%/90% 80% radial-gradient(closest-side,rgba(250,250,218,.3),rgba(250,250,218,0)) no-repeat,-100% -250%/85% 80% radial-gradient(closest-side,rgba(94,225,249,.8),rgba(94,225,249,0)) no-repeat,-170% 100%/70% 60% radial-gradient(closest-side,rgba(94,225,249,.6),rgba(94,225,249,0)) no-repeat,50% 50%/100% 100% linear-gradient(30deg,#6e10ce 10%,rgba(110,16,206,0) 70%,hsla(0,0%,100%,0) 90%) no-repeat,linear-gradient(144deg,rgba(233,235,104,0),rgba(233,235,104,.3)) no-repeat,linear-gradient(90deg,rgba(104,184,235,.11),rgba(15,216,223,.11)) no-repeat,#fff | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| useEffect(() => { | |
| const abortController = new AbortController(); | |
| const {signal} = abortController; | |
| const apiCall = async path => { | |
| try { | |
| const request = await fetch(path, { | |
| signal: signal, | |
| method: 'GET', | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fetchOnClick = async () => { | |
| try { | |
| abortFuncs.current.unshift(abortArticleRequest); | |
| const newArticleRequest = await articleRequest; | |
| const newArticle = await newArticleRequest.json(); | |
| setState([...state, newArticle]); | |
| setArticleId(articleId +1); | |
| } catch(e) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const [articleId, setArticleId] = useState(2); | |
| const [articleRequest, abortArticleRequest] = useGetSingleArticle({articleId: articleId}); | |
| const abortFuncs = useRef([]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {compile} from 'path-to-regexp'; | |
| import {GET_ARTICLE_PATH} from './articles-routes'; | |
| export const useGetSingleArticle = ({ articleId, abortController = new AbortController()}) => { | |
| const baseUrl = 'https://jsonplaceholder.typicode.com'; | |
| const path = baseUrl + compile(GET_ARTICLE_PATH)({articleId}); | |
| const { signal, abort } = abortController || {}; | |
| const articleRequest = fetch(path, { | |
| signal: signal, | |
| method: 'GET', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const Articles = () => { | |
| const [state, setState] = useState([]); | |
| useEffect(() => { | |
| const abortController = new AbortController(); | |
| const {signal} = abortController; | |
| const apiCall = async path => { | |
| try { | |
| const request = await fetch(path, { |
OlderNewer