Skip to content

Commit

Permalink
fix: move to ES6 import for cross-fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Dec 16, 2021
1 parent 11daa98 commit b855273
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/vc-api-issuer/src/agent/VcApiIssuer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { schema } from '../index'
import { events, IIssueCredentialArgs, IRequiredContext, IVcApiIssuer, IVcApiIssuerArgs } from '../types/IVcApiIssuer'
import { VerifiableCredentialSP } from '@sphereon/ssi-sdk-core'

const fetch = require('cross-fetch')
import { fetch } from 'cross-fetch'

/**
* {@inheritDoc IVcApiIssuer}
Expand Down Expand Up @@ -32,7 +32,7 @@ export class VcApiIssuer implements IAgentPlugin {
Authorization: `bearer ${this.authorizationToken}`,
},
body: JSON.stringify({ credential: args.credential }),
}).then(async (response: { status: number; text: () => string | PromiseLike<string | undefined> | undefined; json: () => string }) => {
}).then(async (response) => {
if (response.status >= 400) {
throw new Error(await response.text())
} else {
Expand Down
6 changes: 3 additions & 3 deletions packages/vc-api-verifier/src/agent/VcApiVerifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IAgentPlugin } from '@veramo/core'
import { schema } from '../index'
import { events, IRequiredContext, IVcApiVerifier, IVcApiVerifierArgs, IVerifyCredentialArgs, IVerifyCredentialResult } from '../types/IVcApiVerifier'

const fetch = require('cross-fetch')
import { fetch } from 'cross-fetch'

/**
* {@inheritDoc IVcApiVerifier}
Expand All @@ -29,14 +29,14 @@ export class VcApiVerifier implements IAgentPlugin {
},
body: JSON.stringify({ verifiableCredential: args.credential }),
})
.then(async (response: { status: number; text: () => string | PromiseLike<string | undefined> | undefined; json: () => string }) => {
.then(async (response) => {
if (response.status >= 400) {
throw new Error(await response.text())
} else {
return response.json()
}
})
.then(async (verificationResult: string) => {
.then(async (verificationResult) => {
await context.agent.emit(events.CREDENTIAL_VERIFIED, verificationResult)
return verificationResult
})
Expand Down

0 comments on commit b855273

Please sign in to comment.