Search text content of files by keyword using the Google Drive API

Example of getting the contents of a Google Doc via the Google Drive REST API in javascript.

Find files by searching their contents using vanilla javascript

const phrase = "search for this phrase"
let fetch_url = `${encodeURIComponent(
let fetch_options = {
method: "GET",
headers: {
    Authorization: `Bearer ${token}`,
    "Content-Type": "application/json",

const response = await fetch(fetch_url, fetch_options);
const json = await response.json();

For other Google Drive API Examples: