Closed anthonymanzo closed 6 years ago
Hi, So I found that the JSON parser was picky in seeing tabs and new lines. So first I removed those from my Post body. But I was still having problems with the built-in JSON.parse throwing errors for unexpected end of input and whatnot. Here was my final solution (I used npm json-parse ):
Api.addRoute('recharges/insert-recharge-items-and-post',{authRequired:false},{
post:function(){
let data = this.bodyParams // parsed params
let urlParams = this.queryParams; // parsed get quries
let readable = this.request;
let arrStr =readable._readableState.buffer.toString('utf8');
arrStr = parseJson(arrStr);
return {status: 'success', data: arrStr};
}
});
And somewhere in the code before this Api route:
const parseJson = require('parse-json');
Hi, So far I've traveled down the path of raw body and as a query parameter encoded value, but none of that really works right (json gets escaped).
Here's an example3 of what I'm trying to post:
How would I setup my custom endpoint so I can get ahold of the data as a json array?
Many Thanks!