Get contents of a Google Doc using the Google Drive API

By Mike Sallese ·

Get contents of a Google Doc using vanilla javascript

let fetch_url = `https://www.googleapis.com/drive/v3/files/${fileID}/export?mimeType=text/plain`;
let folder_fetch_options = {
  method: "GET",
  headers: {
    Authorization: `Bearer ${token}`,
    "Content-Type": "application/json",
  },
};

const response = await fetch(fetch_url, folder_fetch_options);
// Text will be a string representation of the Google Doc
const text = await response.text();

For other Google Drive API Examples: https://www.mikesallese.me/tags/google-drive-api-examples

About the author

Mike Sallese. I build Scribbl, an AI note taker with no bot in the call, and a few other pieces of software. Off the computer I am building a straw bale workshop.

X · Medium · GitHub · articles on other sites