Total.js platform
Total.js platform

JavaScript platform for everyone

Geolocation in Total.js

Geolocation in Total.js

  • this tutorial uses a middleware
  • obtained data will be stored in req.geolocation variable
  • this tutorial extends Controller by adding geolocation() method which returns req.geolocation

Create a definition file e.g. geolocation.js:

Usage

Now we extend routes where we want to use Geolocation.

Result:

Tips

  • we can use a global middleware via F.use('geolocation', '*', ['web']);
  • we can store geolocation data in cookies or in a database