WDI-SEA / project-4-issues

Open an issue to receive help on project 4 issues

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cant figure out how to refresh the stuff

anaismveras opened this issue · comments

What stack are you using?

(ex: MERN(mongoose + react), DR(django + react), PEN, etc.)

MERN

What's the problem you're trying to solve?

i get the gaycations from the db but i have to sign out and sign back in to get new gaycations to show in the favroites

Post any code you think might be relevant (one fenced block per file)

App.js

const getGaycations = () => {
		if (user !== null) {
			axios.get('http://localhost:8000/destinations',{
				headers: {
					"Authorization": `Bearer ${user.token}`
				}
			})
			.then(foundGaycations => {
				console.log('this is faves', foundGaycations)
				setGaycations(foundGaycations)
			})
		}
    }

	useEffect(() => {
		getGaycations()
	}, [user])

userGaycation.js

const UsersGaycations = (props) => {

    useEffect(() => {
    }, [props])

    const mapGaycations = props.gaycations.map(place => {
        // console.log('this is place length', place.image_url)
        if (place.image_url.length === 31) {
            return (
                <form>
                <h1>{place.city}</h1>
                <p>There is no image for this city</p>
                <input type="Submit" value="Delete Gaycation" />
                </form>
            )
        } else {
            return (
                <form>
                    <h1>{place.city}</h1>
                    <img src={place.image_url} alt={place.city} />
                    <input type="Submit" value="Delete Gaycation"/>
                </form>
            )
        }
    })


    return (
        <div>
            <h1>Your Gaycation Destinations:</h1>
            {mapGaycations}
        </div>
        
    )
}

If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?

no error

What is your best guess as to the source of the problem?

i am using use effect correctly?

What things have you already tried to solve the problem?

ive trying playing around witht eh useeffect