Last active
May 24, 2020 12:40
-
-
Save vanaf1979/55f0f6b28317f245da7a46f4f7d6e9df to your computer and use it in GitHub Desktop.
Basic post navigation with React and the Wp Rest Api https://since1979.dev/basic-post-navigation-with-react-and-the-wp-rest-api/
This file contains 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
mport React, { useState, useEffect } from "react"; | |
import Axios from "axios"; | |
export default function App() { | |
// ... | |
useEffect(() => { | |
Axios.get("https://example.com/wp-json/wp/v2/posts").then(response => { | |
setPosts(response.data); | |
}); | |
}, [setPosts]); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment