by lloydatkinson · 4y ago · 0 comments
> const m3o = require("m3o")(process.env.M3O_API_TOKEN);
Should be using ES modules, and then allowing the creation of the m3o object with the supplied API token. This future proofs the code, because ES modules are part of the language spec. CommonJS/RequireJS was only ever a hack.
> import { m3o } from 'm3o';
> import { AddressService } from 'm3o/address'
We will potentially move to import in the future, but people asked for require when the examples previously used imports.
With the package you can user import as an ES Module version is available:
> import M3O from 'm3o'; > const m3o = M3O(process.env.M3O_API_TOKEN);
Note: As long as the M3O_API_TOKEN environment variable is provided via a .env file then this is not required to be passed.