import React, { useRef, useEffect, useState } from "react";
import axios from 'axios';
function App() {
const [memes,setMemes] = useState({});
useEffect( ()=> {
const fetchMemes = async () => {
await axios.get("")
.then (response => {
setMemes({memes: response.data.data.memes[(Math.floor(Math.random()*10))]})
console.log(memes)
})
.catch(err => {
console.log(err)
})
}
fetchMemes()
},[]) }
while fetching the api i am getting null response first response returns null response and after the second run or render it return the response : responses returned from the api
with getting this empty array in the first response I cannot perform array.map() as it is a null array please help solving this issue i've been trying many ways but none worked ☹