Support Forums

Not sure where i can add this api call and should only work on submit click

I’m just not sure where that code should be so I can pull the data dynamically. Should it go under gatsby-browser.js ? Or do I need an extra module like Axios or Express ? Or does it go somewhere in my AWS install ?

var request = require(“request”);

var options = { method: ‘GET’,
url: ‘https://api.hubapi.com/contacts/v1/contact/vid/12627374/profile’,
qs: { hapikey: ‘demo’ }
request(options, function (error, response, body) {
if (error) throw new Error(error);


Try Netlify Functions! Unlike the rest of your static site, Netlify Functions allow you to run server-side code.

would you give an example

There are loads of examples on the playground and examples pages.

This is this third time you have posted the same question @userweb.

  1. I added node js code to gatsby node js want to do on click event
  2. This api works only in gatsby node js how i can make it in click event and submit data
1 Like

Hey there, @userweb :wave:

We ask that all Forums members keep related questions in one thread. This is to streamline support conversations and keep any new information in one central, searchable place. I am going to close this current thread. You can continue collaborating on the following thread: I added node js code to gatsby node js want to do on click event