Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A Dark Sky serverless function for Netlify
const fetch = require('node-fetch');
exports.handler = async (event, context) => {
const latitude = event.queryStringParameters.latitude;
const longitude = event.queryStringParameters.longitude;
const response = await fetch(`${process.env.DARK_SKY_KEY}/${latitude},${longitude}`);
const data = await response.json();
return {
statusCode: 200,
body: JSON.stringify(data)
} catch (err) {
return {
statusCode: 500,
body: err.toString()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment