Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fetch('/api/virtual-girlfriend', {
- method: 'post',
- headers: {
- 'Content-Type': 'application/json',
- authorization: `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEsImlhdCI6MTcxMjIyMDIxMSwiZXhwIjoxNzE0ODEyMjExfQ.N_vtUcfC6LkfiMEGZd9xpSxFrGPN13yhCS2g1jfD0Iw`
- },
- body: JSON.stringify({
- "ethnicity": "Asian",
- "age": "20s",
- "body_type": "Skinny",
- "breasts_size": "Small",
- "butt_size": "Skinny",
- "hair_style": "Curly",
- "hair_color": "Black",
- "personality": "Jester",
- "relationship": "School Mate",
- "occupation": "Baker",
- "hobbies": [
- "Art",
- "Diy Crafting",
- "Writing"
- ],
- "clothing": "Skatepark",
- "profile_image": null,
- "name": "Tony Karch"
- })
- }).then(async (response) => {
- // response.body is a ReadableStream
- const reader = response.body.getReader();
- for await (const chunk of readChunks(reader)) {
- const result = new TextDecoder().decode(chunk);
- console.log('Result', result);
- }
- });
- // readChunks() reads from the provided reader and yields the results into an async iterable
- function readChunks(reader) {
- return {
- async* [Symbol.asyncIterator]() {
- let readResult = await reader.read();
- while (!readResult.done) {
- yield readResult.value;
- readResult = await reader.read();
- }
- },
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement