I need to create a google doc but with some html in it. After searching a lot, it looks like it's not possible to just use the google docs api and create a new document with the html, it's not going to convert the text into actual html.
So I found this question, which the person says to upload a html file and convert to a google docs. But it's using PHP and I need to do this only using the REST api, but I just can't get this to work.
In my case, the document is actually created, but with no content.
This code creates the google docs file:
const { body } = await superagent
.post(`https://www.googleapis.com/drive/v3/files`)
.send({
name: 'Some title',
mimeType: 'application/vnd.google-apps.document',
data: '<a href="https://google.com">Google</a>',
})
.set('Authorization', `Bearer ${token}`);
And the part that I don't know what to do is how to upload my html and put into this google doc file.
I'm using superagent to send the request, but the answer can be with fetch, axios or whatever.
And the html content will be a string that I will provide in the frontend, but for now just making it work with <a href="https://google.com">Google</a>" is enough.