Skip to content

Commit

Permalink
fix(http): add headers sdk headers to http config
Browse files Browse the repository at this point in the history
  • Loading branch information
atticusofsparta committed Feb 15, 2024
1 parent fa1cb72 commit 94810ed
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ yarn add @ar-io/sdk
## Quick Start

```typescript
const remoteStateProvider = new ArNSRemoteCache();
const arIO = new ArIO({});
// or
const remoteStateProvider = new ArNSRemoteCache({
url: customUrlToService,
logger: customLoggerFunction
});
const arIO = new ArIO({ contractStateProvider: cache });

const state = arIO.getContractState({
Expand Down
4 changes: 4 additions & 0 deletions src/utils/http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';

import { version } from '../version.js';

// TODO: re-implement axios-retry. Currently latest version of axios-retry is broken for node-next builds on v4.0.0
export interface AxiosInstanceParameters {
axiosConfig?: Omit<AxiosRequestConfig, 'validateStatus'>;
Expand All @@ -28,6 +30,8 @@ export const createAxiosInstance = ({
...axiosConfig,
headers: {
...axiosConfig.headers,
'x-ar-io-sdk-version': `${version}`,
'x-source-identifier': 'ar-io-sdk',
},
validateStatus: () => true, // don't throw on non-200 status codes
});
Expand Down
2 changes: 2 additions & 0 deletions tests/ArIO.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ describe('ArIO Client', () => {

it('should create an ArIO client', () => {
expect(arioClient).toBeInstanceOf(ArIO);
const localClient = new ArIO({});
expect(localClient).toBeInstanceOf(ArIO);
});

it('should get a contract state', async () => {
Expand Down

0 comments on commit 94810ed

Please sign in to comment.