CodePudding user response:
Please give sufficient resource to answer the question. Also attach console error in question.
But i will try answering your question. It may be
- Try Giving in this way
const res = await fetch(apilink
);
const data = await res.json();
and store the data state
Try axios, Its best way
import axios from 'axios' useEffect(()=>{ axios.get(
apilink
).then(res=>{ setData(res.data) }) },[])
CodePudding user response:
try searching for allowed_host/crossOrigin for your backend then add your frontend url Something like this `@Controller @CrossOrigin(origins = "http://localhost:3000") public class MyController {
}`