NOTE The following setup is for a web-setup only. Refer to the page on node.js for information on using the SDKs with node.js, and the page on react-native for information on using the SDKs with React Native
@mitter-io/web
package as a dependency. If you want to use the base models used by mitter, you can also add @mitter-io/models
package, although that is optional.fetch
and axios
. They have been tested to work with both, the browser-bundled fetch and the whatwg-fetch
polyfill. If you do want to use the mitter clients itself, you will need to add axios
as a dependency<mitter-api-url>
, use the following value:mitterApiBaseUrl
key in the config or explicitly set it to https://api.mitter.io
http://localhost:<port>
where the port is port forwarded by docker for 11902
. To find out which port it is, run the following command docker port $(docker ps --filter expose=11901-11903/tcp --format "")
<distributor-url>
, use the following value:weaverUrl
key in the config or explicitly set it to https://weaver.mitter.io
http://localhost:<port>
where the port is port forwarded by docker for 11903
. To find out which port it is, run the following command docker port $(docker ps --filter expose=11901-11903/tcp --format "")
NOTE Setting a user authorization does not check if the provided token was valid. If you wish to verify the token, you can make a call to/v1/users/me
using either the provided API clients (documented below) or using a fetch interceptor
mitter.clients()
call. On the returned object, then get the relevant client as you desire:@mitter-io/models
package):NOTE Themitter.me
returns a user-like object that can be used in any place in API calls which require a user identifier.
fetch
fetch
one can use the fetch-interceptor
axios
interceptor, intercepts all fetch requests globally. This is due to the fact that fetch
as an object itself happens to be declared in a global scope. The interceptor simply adds the user authorization to your mitter.io api requests (as headers) and will only intercept requests that are made to either https://api.mitter.io
or https://api.staging.mitter.io
. If you do not wish to have a global interceptor, a simpler solution would be to add the header yourself:axios
(and we recommend using it for making mitter.io API calls), then you can enable an interceptor on a specific axios instancefetch
interceptor, even the axios interceptor will intercept only the requests that start with https://api.mitter.io
and https://staging.api.mitter.io
.mitter
object, it automatically creates relevant pipelines to process incoming payloads. Mitter.io pushes different payloads to users on relevant activity. A few examples are:subscribeToPayload
function:@mitter-io/models
also bundles with a number of type-identifying functions that can be used instead of custom matching. Using that, the same code would now look like:clearSubscriptions
method: