You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: typescript/@ragbits/api-client/README.md
+9-2Lines changed: 9 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,12 @@ import { RagbitsClient } from '@ragbits/api-client'
25
25
// Initialize the client
26
26
const client =newRagbitsClient({
27
27
baseUrl: 'http://127.0.0.1:8000', // Optional, defaults to http://127.0.0.1:8000
28
+
auth: {
29
+
getToken: () =>'token',
30
+
onUnauthorized: () => {
31
+
console.warn('⚠️ Unauthorized')
32
+
},
33
+
}, // Optional, used to provide auth details
28
34
})
29
35
30
36
// Get API configuration
@@ -80,6 +86,7 @@ new RagbitsClient(config?: ClientConfig)
80
86
**Parameters:**
81
87
82
88
-`config.baseUrl` (optional): Base URL for the API. Defaults to 'http://127.0.0.1:8000'
89
+
-`config.auth` (optional): An object containing authentication details. Provide `getToken` to automatically attach `Authorization: Bearer <token>` to every request. `onUnauthorized` is called if the library encounters a 401 status code.
0 commit comments