Skip to content

Commit

Permalink
handle JSON response outside http-client
Browse files Browse the repository at this point in the history
  • Loading branch information
beaulac authored and dmitrizagidulin committed Apr 8, 2024
1 parent 6be54f0 commit a850e3e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/documentLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const httpClientHandler = {
'Cache-Control': 'no-cache',
'Pragma': 'no-cache'
};
result = await httpClient.get(params.url, { headers });
result = await httpClient.get(params.url, { headers, parseBody: false });
} catch(e: any) {
throw new Error(`NotFoundError loading "${params.url}": ${e.message}`);
}
Expand Down
8 changes: 8 additions & 0 deletions test/documentLoader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ describe('documentLoader', () => {
.equal('did:key:z6MkhVTX9BF3NGYX6cc7jWpbNnR7cAjH8LUffabZP8Qu4ysC');
});

it('should load v2 context from web', async () => {
const documentLoader = securityLoader({fetchRemoteContexts: true}).build();

const url = 'https://www.w3.org/ns/credentials/v2';
const result = await documentLoader(url);
expect(result.document).to.exist;
});

it('supports beta OBv3 context', async () => {
const load = securityLoader().build()
const { document } = await load('https://purl.imsglobal.org/spec/ob/v3p0/context.json')
Expand Down

0 comments on commit a850e3e

Please sign in to comment.