I would like to post on my Wordpress blog using API. Since I'm in a Javascript application I would do that using this language.
I have made some searches and I have found node-wpapi package, that uses Wordpress XML-RPC protocol. Everything works, except posting article with media or featured image.
const responseUploadImage = await wp.media()
.file('./tempImage.jpg')
.create({
title: 'My awesome image',
alt_text: 'an image of something awesome',
caption: 'This is the caption text',
description: 'More explanatory information'
});
const responsePostCreation = await wp.posts().create({
title: 'Your Post Title',
content: 'Your post content',
// status: 'publish'
});
const response = await wp.media().id(responseUploadImage.id).update({
post: responsePostCreation.id
});
It does create post and upload media, but it doesn't create post with media.
Do you know alternative or a better way to create posts with media and featured image with a JS library?