0

I'm calling Google Books API in a project using Firebase with code similar to this post.

However, I'm running into an issue with production. When I try this locally I can connect to the Google Books API no problem, but it keeps failing on production with a 500 error and the only details I get are:

{"error":{"message":"INTERNAL","status":"INTERNAL"}}

Any ideas what I should try here? I've set my API key to be unrestricted in the developer's console and am stuck.

Here is my cloud call from firebase:

export const getGoogleBooks = functions.https.onCall(
    async function(data: any, context: functions.https.CallableContext) {
       const query: string = data.query;
       console.log(`Received query loud and clear: ${query}`);
       try {
          const res = await fetch(`https://www.googleapis.com/books/v1/volumes?q=${query}&key=xxxx`);
          const json = await res.json();
          return json;
       } catch(err) {
          throw new functions.https.HttpsError("internal", 'Failed to search books online');
       }
    }
);

Here is what my API key permissions look like in Google Console: Google API Console

My requests seem fine when I try them locally, in Postman, or a Browser, but on production I'm getting the error message mentioned above.

master_chef
  • 345
  • 1
  • 3
  • 9

0 Answers0