XD2Sketch / react-chat-stream

⚛️ React Hook to add 🤖 ChatGPT-like word-by-word event streams
https://www.npmjs.com/package/@magicul/react-chat-stream
MIT License
49 stars 10 forks source link

fix: actually use "body" property #12

Closed wcelery closed 10 months ago

wcelery commented 10 months ago

I've noticed, that when you use method.type: 'body' nothing really happens and we're not sending payload. This PR fixes it.

niels-bosman commented 10 months ago

@wcelery Thanks for contributing! In the case that the body is not set, doesn't this send 'null' or 'undefined' as the body? I would like to have a check here to make sure we don’t send stringified null values to the API.

wcelery commented 10 months ago

@niels-bosman Hi. If body is undefined, no payload will be sent (JSON.stringify handles it for us) and if body is null, we're converting null -> undefined by JSON.stringify's replacer function.

kgoedecke commented 10 months ago

@wcelery @niels-bosman thanks a lot for fixing this, looks good to me!