Skip to content

Commit

Permalink
update node client docs (#117)
Browse files Browse the repository at this point in the history
Co-authored-by: Tate <tate@transcriptic.com>
  • Loading branch information
tatethurston and Tate authored Feb 2, 2022
1 parent fb228f3 commit 2fbed59
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,12 @@ import { nodeHttpTransport } from "twirpscript/dist/node";
import { MakeHat } from "../protos/haberdasher.pb";

client.baseURL = "http://localhost:8080";

// This is provided as a convenience for Node.js clients. If you provide `fetch` globally, this isn't necessary and your client can look identical to the browser client above.
client.rpcTransport = nodeHttpTransport;

(async function () {
try {
const hat = await MakeHat({ inches: 12 });
console.log(hat);
} catch (e) {
console.error(e);
}
})();
const hat = await MakeHat({ inches: 12 });
console.log(hat);
```

See a [Node.js client example](https://github.com/tatethurston/TwirpScript/blob/main/twirp-clientcompat/src/client-harness.ts#L11-L12).
Expand Down
15 changes: 6 additions & 9 deletions examples/server-to-server/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ import { MakeHat, MakeHatJSON } from "./protos/haberdasher.pb";
client.baseURL = "http://localhost:8080";
client.rpcTransport = nodeHttpTransport;

(async function () {
try {
let hat = await MakeHat({ inches: 12 });
console.log(hat);
hat = await MakeHatJSON({ inches: 11 });
console.log(hat);
} catch (e) {
console.error(e);
}
(async () => {
const hat = await MakeHat({ inches: 12 });
console.log(hat);

const hatJSON = await MakeHatJSON({ inches: 11 });
console.log(hatJSON);
})();

0 comments on commit 2fbed59

Please sign in to comment.