Skip to content

Instantly share code, notes, and snippets.

@vanaf1979
Created May 25, 2020 13:19
Show Gist options
  • Save vanaf1979/0bf5ff39224425f0296593d3e8364fed to your computer and use it in GitHub Desktop.
Save vanaf1979/0bf5ff39224425f0296593d3e8364fed to your computer and use it in GitHub Desktop.
import React, { useState, useEffect } from "react";
import Axios from "axios";
import WpApiContent from "./WpApiContent.js";
export default function App() {
const [post, setPost] = useState(null);
useEffect(() => {
Axios.get("https://since1979.dev/wp-json/wp/v2/posts/1601").then(
response => {
setPost(response.data);
}
);
}, [setPost]);
return (
<div className="App">
{post && (
<div>
<h1>{post.title.rendered}</h1>
<WpApiContent content={post.content.rendered} />
</div>
)}
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment