Typescript SDK
Fetch your Client SDK​
You can simply download the typescript client code with the following command line:
terminalbash
npx fetch-bridge-sdk $serverUrl
terminalbash
npx fetch-bridge-sdk $serverUrl
If you do not have axios and form-data installed in your project, the command line will automatically install them for you.
The upcoming version of the command line will allow you to select your preferred HTTP client library, either axios or fetch, and the required packages will be automatically installed if they are not already present in your project.
Use it in the frontend​
The Typescript client SDK exports an API constant which can be easily imported into your code and used to access every endpoint of the Bridge API.
Example​
client.tsts
// import { API } from './api'Âasync () => {Âconst {data ,error } = awaitAPI .user .getMe ({headers : {token : 'secretToken' }})Âif (data )console .log (data )ÂÂif (error ) {switch (error .name ) {case "User not found"://...break;}Âconsole .log (error )}}
client.tsts
// import { API } from './api'Âasync () => {Âconst {data ,error } = awaitAPI .user .getMe ({headers : {token : 'secretToken' }})Âif (data )console .log (data )ÂÂif (error ) {switch (error .name ) {case "User not found"://...break;}Âconsole .log (error )}}