Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- import logo from './logo.svg';
- import './App.css';
- class App extends Component {
- render() {
- // Sample usage of the `wp.api` script.
- let wpPosts = new window.wp.api.collections.Posts();
- wpPosts.fetch({ data: { per_page: 2 } }).done( posts => {
- posts.forEach( post => {
- console.log(post.title.rendered);
- });
- });
- return (
- <div className="App">
- <header className="App-header">
- <img src={logo} className="App-logo" alt="logo" />
- <p>
- Edit <code>react-src/src/App.js</code> and save to reload.
- </p>
- <a
- className="App-link"
- href="https://reactjs.org"
- target="_blank"
- rel="noopener noreferrer"
- >
- Learn React
- </a>
- </header>
- </div>
- );
- }
- }
- export default App;
Add Comment
Please, Sign In to add comment