Hey guys I am testing out netlify dev
command to test functions locally. I am running into an issue.
Seems like its not recognizing "import"
Actual error:
import fetch from 'node-fetch'
^^^^^^
SyntaxError: Unexpected token import
My function file:
import fetch from 'node-fetch'
exports.handler = async (event, context, callback) => {
const behanceEndpoint = `https://www.behance.net/v2/users/jhackett1/projects?api_key=${
process.env.BEHANCE_API_KEY
}`
const response = await fetch(behanceEndpoint)
const data = await response.json()
return {
statusCode: 200,
body: JSON.stringify(data.projects)
}
}
P.S. How do I setup local variables for dev?