Using Netlify functions with GatsbyJs and Google Sheets API

Click for: original source

Ivo Šiško has written this article about how to extend your JAMstack application with some dynamic functionality using serverless. He will guide you on his journey of implementation 2 dynamic features to static page.

The first feature was to offer the product for the user when he enters the web page and if he is interested, ask him to fill a two-field form to get the product in the e-mail. The second feature was saving that info in the Google Sheets on the Drive using the Google Sheets API.

As the web page is just a simple static page with no backend and simple cms, hosted on the Netlify, author opted for the Netlify functions.

The article then provides all the necessary information about:

  • Feature 1: Sending an email
  • Feature 2: Interacting with the Google Sheets

To be able to test the functions while developing them itt is easiest to use Netlify dev CLI. It allows us to manually invoke the functions, test them and logging in the console, just by starting the dev environment using netlify dev or ntl dev command.

Since the client already had an account on Sendgrid, Ivo used the Sendgrid API to send the email via @sendgrid/mail – the official package for node from Sendgrid. All steps are explained with all the needed code provided. Good read!

[Read More]

Tags web-development frontend serverless javascript