Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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