Nfetch local save

Hi there!
I’m trying to Save Json file in local disk.
I’m useing Nfetch in javascript node and “POST JSON data” method in Notch reference Manual.
but, not working.

code:
/////////////
payload = {
“mydata”: “is awesome”,
“myNumber”: 42
};

req = { method: ‘POST’, body: JSON.stringify(payload), headers: { ‘Content-Type’: ‘application/json’ } };
NFetch(“c:/test.json”, req, testPostJSONResponse); /// URL replace localpath.

function testPostJSONResponse(response) {
if (response.ok && response.status === 200) {
Log(‘POST JSON success’);
}
}
///////
Where is wrong this code?

please help!!!

If I understand correctly, you are trying to save the response from an HTTP call to disk.

If so, you need to add the saveToPath attribute to the request JSON.

req = { method: ‘POST’, body: JSON.stringify(payload), headers: { ‘Content-Type’: ‘application/json’ }, saveToPath: 'c:/test.json' };

And your NFetch request should be:

NFetch("<myAPIURL>", req, testPostJSONResponse)

Thank you response luke.malcolm.

I want to save Text file or json file to local disk.
I don’t need to the response from an HTTP call.
I’m Looking for a way to save in json from Notch parameter data.
Is there any good way?