'Mapbox configuration is not working. Can not pass access token
I'm trying to implement geocoding to my express app and I decided to use MapBox client API. However when I tried to configure it, it's still throwing following error. Please help me
Error: Cannot create a client without an access token
at NodeClient.MapiClient (D:\NODE COURSE\Colt Steele\DerpCamp\node_modules\@mapbox\mapbox-sdk\lib\classes\mapi-client.js:25:11)
at new NodeClient (D:\NODE COURSE\Colt Steele\DerpCamp\node_modules\@mapbox\mapbox-sdk\lib\node\node-client.js:7:14)
at createNodeClient (D:\NODE COURSE\Colt Steele\DerpCamp\node_modules\@mapbox\mapbox-sdk\lib\node\node-client.js:24:10)
at D:\NODE COURSE\Colt Steele\DerpCamp\node_modules\@mapbox\mapbox-sdk\services\service-helpers\create-service-factory.js:13:16
at Object.<anonymous> (D:\NODE COURSE\Colt Steele\DerpCamp\src\controllers\CampgroundController.js:6:18)
Here is my configuration
const Geocoding = require('@mapbox/mapbox-sdk/services/geocoding')
const map_token = process.env.MAPBOX_TOKEN
const geocoder = Geocoding({accessToken: map_token})
VERY IMPORTANT NOTE
There is no space between MAPBOX_TOKEN and my actual api key in my dev.env file.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
