Skip to content
A token/key obscuring function for API calls using Netlify functions.
JavaScript CSS HTML
Branch: master
Clone or download
depadiernos Merge pull request #5 from depadiernos/dependabot/npm_and_yarn/safer-…

Bump safer-eval from 1.3.3 to 1.3.5
Latest commit 886caee Dec 16, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
src put a nice shadow around the 'modal' Jun 16, 2019
.gitignore Initial commit for API token/key hider Apr 10, 2018 Update Jun 15, 2019
package-lock.json Bump safer-eval from 1.3.3 to 1.3.5 Oct 21, 2019
package.json Update package.json Sep 24, 2019

Token Hider

This is an example of hiding the API token/key for API calls using Google Maps API and Netlify Functions.

Live demo

TL;DR deploy to Netlify



When you deploy your site to Netlify, you'll need to define the following Environment Variables in the UI.

Testing locally

1. Install

Clone the repo and go to function_examples/token-hider and npm install.

2. Run Lambda Functions

Type in the following script in your console: export API_URL="" && export API_TOKEN="<your Google Maps API token>" && npm run lambda:dev This will start a local dev server. Requests to http://localhost:9000/getapi will route to functions/getapi.js.

To test, add a query to retrieve a specific data object, e.g.: localhost:9000/getapi?address=220+Stanhope+St,+Brooklyn,+NY

3. Run site

Open a new console and type in: npm run site:dev The site is now available at http://localhost:1234/

Notes: Make sure you run Functions first before you run the site.

To test, go to localhost:1234 and enter and address and hit 'submit'

4. Run both

To run both function and site servers, use npm start.

You can’t perform that action at this time.