# I am trying to append response of an API (Multiple Iterations) in single file

**URL:** <https://community.postman.com/t/i-am-trying-to-append-response-of-an-api-multiple-iterations-in-single-file/33019>\
**Category:** Help Hub\
**Created:** [February 28, 2022, 11:46am UTC](https://community.postman.com/t/i-am-trying-to-append-response-of-an-api-multiple-iterations-in-single-file/33019 "2022-02-28T11:46:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cryosat-participant2](https://avatars.discourse-cdn.com/v4/letter/c/dc4da7/32.png) [@cryosat-participant2](https://community.postman.com/u/cryosat-participant2)\
**Post date:** [February 28, 2022, 11:46am UTC](https://community.postman.com/t/i-am-trying-to-append-response-of-an-api-multiple-iterations-in-single-file/33019/1 "2022-02-28T11:46:11Z")

</div>

// The opts for the server, also includes the data to be written to file  
let opts = {  
requestName: request.name || request.url,  
fileExtension: ‘json’,  
mode: ‘appendFile’, // Change this to any function of the fs library of node to use it.  
uniqueIdentifier: false,  
responseData: pm.response.text()  
};  
pm.sendRequest({  
url: ‘[http://localhost:3000/write](http://localhost:3000/write)’,  
method: ‘POST’,  
header: ‘Content-Type:application/json’,  
body: {  
mode: ‘raw’,  
raw: pm.response.text()  
}  
}, function (err, res) {  
console.log(res);  
});

I am using the above snippet , but the file has only response of first request and i am able to see “Internal Server error” -500 in all the iterations after POST operation

TypeError [ERR\_INVALID\_ARG\_TYPE]: The “data” argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined  
at Object.writeFile (node:fs:2108:5)

The saved file under Responses folder has only response of first request

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [December 12, 2024, 12:54pm UTC](https://community.postman.com/t/i-am-trying-to-append-response-of-an-api-multiple-iterations-in-single-file/33019/2 "2024-12-12T12:54:15Z")

</div>

Closed on December 12, 2024, 12:54pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
