mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
chore: add examples
This commit is contained in:
34
packages/api/v1/examples/06-update-a-recipient.ts
Normal file
34
packages/api/v1/examples/06-update-a-recipient.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { initClient } from '@ts-rest/core';
|
||||
|
||||
import { ApiContractV1 } from '../contract';
|
||||
|
||||
const main = async () => {
|
||||
const client = initClient(ApiContractV1, {
|
||||
baseUrl: 'http://localhost:3000/api/v1',
|
||||
baseHeaders: {
|
||||
authorization: 'Bearer <my-token>',
|
||||
},
|
||||
});
|
||||
|
||||
const documentId = '1';
|
||||
const recipientId = '1';
|
||||
|
||||
const { status } = await client.updateRecipient({
|
||||
params: {
|
||||
id: documentId,
|
||||
recipientId,
|
||||
},
|
||||
body: {
|
||||
name: 'Johnathon Doe',
|
||||
},
|
||||
});
|
||||
|
||||
if (status !== 200) {
|
||||
throw new Error('Failed to update recipient');
|
||||
}
|
||||
};
|
||||
|
||||
main().catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user