1
var request = require('request');
var fs=require("fs");

var program = {
    script :"print('hello\nworld')",
    language: "python3",
    versionIndex: "0",
    clientId: "clientID",
    clientSecret:"clientSecret"
};
request({
    url: 'https://api.jdoodle.com/execute',
    method: "POST",
    json: program
},
function (error, response, body) {
    console.log('error:', error);
    console.log('statusCode:', response && response.statusCode);
    console.log('body:', body);
});

output:

error: null
statusCode: 200
body: { output: '\njdoodle.c:1:7: warning: missing terminating \' character\n print(\'hello\n       ^\njdoodle.c:1:1: error: missing terminating \' c
haracter\n print(\'hello\n ^\njdoodle.c:2:6: warning: missing terminating \' character\n world\')\n      ^\njdoodle.c:2:1: error: missing terminating
 \' character\n world\')\n ^\njdoodle.c:2:1: error: expected \')\' at end of input\n',
  statusCode: 200,
  memory: null,
  cpuTime: null }

Is there any other way to send code to compiler api to execute it please suggest me Thanks for helping me in advance

mannem srinivas
  • 111
  • 2
  • 6

2 Answers2

0

try

script :"print('hello\\nworld')",
Twinkle
  • 191
  • 2
  • 12
0

use textArea to in the form to fetch the code it will automatically change the code to jDoodle understandable format.
and only for here:

script :"print('hello\r\nworld')",