Skip to content

Commit a449250

Browse files
committed
Updated client to allow usage of FormData from node since it has been available through node since v16 and client requires >v18. Fixed 405 throws test due to change in error message format.
1 parent 06278ea commit a449250

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

Diff for: src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,7 @@ export function createFieldError(fieldName:string, message:string, errorCode:str
15341534
return new ResponseStatus({ errors:[new ResponseError({fieldName, errorCode, message})] })
15351535
}
15361536

1537-
export function isFormData(body:any) { return typeof window != "undefined" && body instanceof FormData }
1537+
export function isFormData(body:any) { return body instanceof FormData }
15381538

15391539
function createErrorResponse(errorCode: string|number, message: string, type:ErrorResponseType=null) {
15401540
const error = apply(new ErrorResponse(), e => {

Diff for: tests/client.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ describe ('JsonServiceClient Tests', () => {
8787
const api = await testClient.api(new dtos.Overview())
8888

8989
expect(api.errorCode).to.be.equal('NotImplementedException')
90-
expect(api.errorMessage).to.be.equal('The operation \'Overview\' does not exist for this service')
90+
expect(api.errorMessage).to.be.equal('The operation does not exist for this service')
9191
})
9292

9393
it('Should throw 401', async () => {

Diff for: tests/usages.spec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const { expect, assert } = chai
33
import {
44
each,
55
JsonServiceClient,
6+
isFormData
67
} from '../src/index'
78

89
describe ('Usages Tests', () => {
@@ -32,4 +33,9 @@ describe ('Usages Tests', () => {
3233
expect(r.c).eq(1)
3334
})
3435

36+
it ('Does allow usage of FormData from node', () => {
37+
const formData = new FormData()
38+
formData.append('a', 'b')
39+
})
40+
3541
})

0 commit comments

Comments
 (0)