Skip to content

Instantly share code, notes, and snippets.

@yann-yinn
Created June 13, 2017 11:00
Show Gist options
  • Save yann-yinn/92a219f491754551fd760e99312c3cf7 to your computer and use it in GitHub Desktop.
Save yann-yinn/92a219f491754551fd760e99312c3cf7 to your computer and use it in GitHub Desktop.
Get data property from response returned by Axios
const endpoint = 'https://public-api.wordpress.com/wp/v2/sites/yineo.fr'
const axios = require('axios')
async getPosts (perPage = 10) {
return {data} = await axios.get(endpoint + '/posts?_embed&per_page=' + perPage)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment