Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@WouterNieuwerth
Created February 27, 2022 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WouterNieuwerth/208c3acf1caead317f416915e3e2e651 to your computer and use it in GitHub Desktop.
Save WouterNieuwerth/208c3acf1caead317f416915e3e2e651 to your computer and use it in GitHub Desktop.
An example of a server-side GTM variable template that doesn't work ufortunately.
// A variable template that doesn't work, because it uses an asynchronous API.
const JSON = require('JSON');
const sendHttpRequest = require('sendHttpRequest');
sendHttpRequest('https://api.openweathermap.org/data/2.5/weather?lat=52.3746027&lon=6.6810724&appid=[enter_api_key_here]&units=metric&lang=nl', (statusCode, headers, response) => {
response = JSON.parse(response);
return response;
}, {method: 'GET', timeout: 2000});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment