Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import MapboxClient from 'mapbox';
export const mapboxToken = 'pk.eyJ1IjoiYWRob2MiLCJhIjoiY2l2Y3VlNWp5MDBoNjJvbHZ2a3R4bnN2cyJ9.2LoUhwRmz2OiCtRirnc6Pw';
export const mapboxClient = new MapboxClient(mapboxToken);
export default mapboxClient;
constructor(props) {
super(props);
this.state = {
text: '',
locations: [],
selectedLocation: null,
error: null
};
this.mapbox = new MapBox(process.env.MAPBOX_API_TOKEN);
this.attemptGeoLocation = this.attemptGeoLocation.bind(this);
this.handleLocationUpdate = this.handleLocationUpdate.bind(this);
this.handleSearchChange = this.handleSearchChange.bind(this);
this.handleSelectLocation = this.handleSelectLocation.bind(this);
this.resetSearch = this.resetSearch.bind(this);
}
componentDidUpdate(prevProps, prevState) {
componentDidMount() {
MapboxGL.setAccessToken(this.props.mapBoxApiKey);
this.mapboxClient = new MapboxClient(this.props.mapBoxApiKey);
this.downloadRoute();
}
import { mapboxToken } from '../utils/mapboxToken';
import environments from '../../../platform/utilities/environment';
/**
New: @mapbox/mapbox-sdk is initialized with the accessToken key as an object
The conditional is for using the SDK version according to the environment ( New SDK in staging temporarily for QA)
TODO: remove this logic after new sdk tested in staging
MapboxClient1 : New SDK
MapboxClient2 : Current SDK
*/
export const mapboxClient = environments.isStaging()
? new MapboxClient1({ accessToken: mapboxToken })
: new MapboxClient2(mapboxToken);
export default mapboxClient;