Skip to content

Instantly share code, notes, and snippets.

@richardgrantserverless
Created March 22, 2022 21:28
var callExternalApi = async function (latitude, longitude) {
try {
var response = await fetch(`${apiUrl}/${apiKey}/${latitude},${longitude}`);
var json = await response.json();
var body = { temperature: json.currently.temperature }
var response = {
statusCode: 200,
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(body)
};
return response;
} catch (error) {
console.log(error);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment