mapbox / mapbox-sdk-js

A JavaScript client to Mapbox services, supporting Node, browsers, and React Native
Other
718 stars 186 forks source link

Missing documentation and types for BrowserClient #367

Open chriszrc opened 4 years ago

chriszrc commented 4 years ago

The usage docs here:

https://github.com/mapbox/mapbox-sdk-js#usage

Don't mention anything about needing to pass in the "BrowserClient" when using services from a web app, e.g. :

import mbxClient from "@mapbox/mapbox-sdk/lib/browser/browser-client";
import mbxGeocoding from "@mapbox/mapbox-sdk/services/geocoding";

const baseClient = mbxClient({
  accessToken: process.env.REACT_APP_MAPBOX_ACCESS_TOKEN,
});
const geocodingService = mbxGeocoding(baseClient);

And then, once you figure that out, typescript complains about the browser-client import because there are no typings for that module :(

andrewharvey commented 4 years ago

Hmm I use this library all the time in the browser and have never needed to touch browser-client I just follow per the usage

const mbxClient = require('@mapbox/mapbox-sdk');
const mbxStyles = require('@mapbox/mapbox-sdk/services/styles');
const mbxTilesets = require('@mapbox/mapbox-sdk/services/tilesets');

const baseClient = mbxClient({ accessToken: MY_ACCESS_TOKEN });
const stylesService = mbxStyles(baseClient);
const tilesetsService = mbxTilesets(baseClient);

Is this wrong? I thought that this library worked out internally if it was in the browser on in node.

And then, once you figure that out, typescript complains about the browser-client import because there are no typings for that module :(

Sorry I don't use typescript so can't help there but see #213 for context, I presume you can use externally maintained typescript definitions?

andrewharvey commented 4 years ago

Also some typescript work happening at #361, but again I don't use typescript so out of my depth here.