36
loading...
This website collects cookies to deliver better user experience
fetch('https://jsonplaceholder.typicode.com/todos/1')
.then(response => response.json())
.then(json => console.log(json))
async function fetchData() {
const response = await fetch(
"https://jsonplaceholder.typicode.com/todos/3"
);
const data = await response.json();
console.log(data);
npm install axios
import axios from "axios"
React.useEffect(() => {
axios.get("https://jsonplaceholder.typicode.com/todos/3")
.then((response) => (console.log(response));
}, []);
import { useEffect } from "react";
const useFetch = (url) => {
useEffect(() => {
fetch(url)
.then((response) => response.json())
.then((data) => {
console.log(data);
});
}, []);
};
export default useFetch;