Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fetch('localhost:1337/rest/api', {
- body: JSON.stringify( {name: "Sidd", "info": "Lorem ipsum dolor .."} ),
- headers: {
- 'Accept': 'application/json, text/plain, */*',
- 'Content-Type': 'application/json'
- },
- mode: 'no-cors',
- method: 'post'
- })
- console.log(req.body) // On logging the request body
- {} // am getting this [empty]
- $.ajax('localhost:1337/rest/api', {
- type: 'post',
- data: {name: "Sidd", "info": "Lorem ipsum dolor .."},
- dataType: 'application/json',
- success: function (data, status, xhr) {
- console.log('status: ' + status + ', data: ' + data);
- },
- error: function (jqXhr, textStatus, errorMessage) {
- console.log('Error' + errorMessage);
- }
- });
- app.use(bodyParser.json({limit: '2mb'})); // 2mb file upload limit
- app.use(bodyParser.urlencoded({limit: '2mb', extended: true})); // 2mb file upload limit
Add Comment
Please, Sign In to add comment