[ netlify ] function


  # add function folder
  functions = "functions"


/hello /.netlify/functions/hello 200

Create netlify function

netlify functions:create hello
Created functions/hello/hello-world.js
async function hello() {
  return Promise.resolve("Hello, World");

exports.handler = async function(event, context, callback) {
  try {
    const body = await hello();
    callback(null, { statusCode: 200, body })
  } catch (err) {
    callback(null, { statusCode: 500, body: err.toString() })

Test URL : http://localhost:8000/.netlify/functions/hello

netlify functions:create fauna
template : js-fauna-crud # install npm fauna ( object database ) and create fauna CRUD endpoint

Turn it into npm project

npm init
npm i random-name

Give the random first name

const random = require('random-name')

ref : https://www.netlify.com/docs/functions/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s