Use geolib as netlify function
Simple API to run the Geolib functions as serverless functions on netlify. Find out more about Geolib and netlify functions at the original Resources
yarn install
yarn dev
This starts a local Lambda server.
After that you can test the endpoints with Postman.
Install Postman and import the Collection from the static folder.
In my case the local Lambda server is listening on 9000, so the variable base_url_geolib
is
http://localhost:9000
You can change this variable in the Collection Settings or add your own Environment Variable.
To use the API make a HTTP POST Request and pass the arguments as json in the body
Method: POST
Endpoint: /getDistance
Query: body
{
"start": {
"latitude": 51.5103,
"longitude": 7.49347
},
"end": {
"latitude": "51° 31' N",
"longitude": "7° 28' E"
}
}
Deploy the functions to your netlify account by clicking the button und following the provided steps.
Afterwards you will find the functions under the functions item in your netlify project.
To test the endpoints with the Postman Collection you have to change the base_url_geolib
variable to your netlify site name and the funtions path