Payload
Request data
Adding data to the requests is pretty simple. Use the setData
method on the request and set whatever data you want to
transfer.
Setting data for request
To set data of our request we need to use method .setData()
.
const createUser = client.createRequest<ResponseType, DataType>()({ method: "POST", endpoint: "/users" });
const request = createUser.setData({ name: "Maciej" }); // Must match `DataType`
console.log(request.data); // Output: { name: "Maciej" }