Skip to content

Commit

Permalink
Added wrapper to fetch method (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderKolberg committed Nov 16, 2022
1 parent 7c5e115 commit 1400f3e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion _examples/node-ts/webapp/client.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class ExampleService implements ExampleService {

constructor(hostname: string, fetch: Fetch) {
this.hostname = hostname
this.fetch = fetch
this.fetch = (input: RequestInfo, init?: RequestInit) => fetch(input, init)
}

private url(name: string): string {
Expand Down
5 changes: 1 addition & 4 deletions _examples/node-ts/webapp/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { ExampleService } from './client.gen'

const exampleService = new ExampleService(
'http://localhost:3000',
(input, init) => fetch(input, init)
)
const exampleService = new ExampleService('http://localhost:3000', fetch)

document.addEventListener('DOMContentLoaded', () => {
const pingButton = document.getElementById('js-ping-btn')
Expand Down
2 changes: 1 addition & 1 deletion client.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class {{.Name}} implements {{.Name}} {

constructor(hostname: string, fetch: Fetch) {
this.hostname = hostname
this.fetch = fetch
this.fetch = (input: RequestInfo, init?: RequestInit) => fetch(input, init)
}

private url(name: string): string {
Expand Down

0 comments on commit 1400f3e

Please sign in to comment.