This is the code I'm using. It doesn't work because client.getPosts is async. So my question is, how can I make it work? client.getPosts is from the wordpress npm module so I cannot change it.
// FUNCTIONS
function getAllPosts() {
return client
.getPosts( {type: 'post', status : 'publish', number : 222} , ['title','id'] , (error, posts) => {
return posts
.map((item) => {
return item.title
})
})
}
// MAIN
console.log(getAllPosts());