Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting error 422 #15

Open
mimi-uxui-dev opened this issue Jun 9, 2021 · 0 comments
Open

Getting error 422 #15

mimi-uxui-dev opened this issue Jun 9, 2021 · 0 comments

Comments

@mimi-uxui-dev
Copy link

here's my code, when i refresh i get error 422, i'm trying to use this with search

import React, { useEffect, useState } from 'react'
import parse from 'html-react-parser'
import axios from 'axios'
import { SEARCH } from '../sevices/globalServices'
import { Pagination } from 'react-laravel-paginex'

function SearchPage(props) {

     const form_data = props.location.state

     const [data, setdata] = useState([])



     const getData = (data) => {

          axios.post(`${SEARCH()}page?=${data.current_page + 1}`, form_data).then(response => {
               setdata(response.data);
               console.log('getDAta', data)
          });

     }

     useEffect(() => {

          const fetchDAta = async () => {

               await axios.post(SEARCH(), form_data).then(response => {
                    setdata(response.data);
                    console.log('data', data)
               });
          }

          fetchDAta()
     }, [data])


     return (
          <div className='searchPage_container'>
               <h1> Search Page </h1>
               <div className="searchPage_grid">
                    {/* {
                         data.length === 0 ?
                              <p></p>
                              :
                              data.data.map(d => <div className="SearchPage_grid_card">
                                   <img className='searchImg' src={d.photo} alt="" />
                                   <div className='searchInfo'>
                                        <h4>{d.title__fr || d.name__fr}</h4>
                                        <p> {parse(`${d.text__fr || d.description__fr}`)} </p>
                                   </div>
                              </div>)
                    } */}
               </div>

               <div>
                    <Pagination changePage={getData} data={data} />
               </div>

          </div>
     )
}

export default SearchPage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant