Created
September 4, 2020 12:41
-
-
Save kianaditya/0f0d7b045b63b635d4e43faec3fa06ef to your computer and use it in GitHub Desktop.
cypress toggle mocked routes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect } from 'react' | |
import Axios from 'axios' | |
const URL = 'https://jsonplaceholder.typicode.com/todos' | |
const App = () => { | |
const [todos, setTodos] = useState([]) | |
useEffect(() => { | |
fetchTodos() | |
}, []) | |
const fetchTodos = async () => { | |
const response = await Axios.get(URL) | |
setTodos(response.data) | |
} | |
return ( | |
<div> | |
{todos.map((todo) => { | |
return ( | |
<div key={todo.id}> | |
<h3>{todo.title}</h3> | |
</div> | |
) | |
})} | |
</div> | |
) | |
} | |
export default App |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment