My goal is to generate dynamic code based on the user input, and then have that code programmatically put to jsfiddle so the user can preview the generated code as well as the running result.
I've tried using the jsfiddler library which utilizes phantomjs for the job, but the only output I am getting is:
Failed to create JS Fiddle Failed with code: Error: spawn /Users/***/test/untitled folder/untitled folder/jsfiddler/node_modules/phantomjs/bin/phantomjs ENOENT
Here is my javascript code:
var jsfiddler = require("./jsfiddler");
let options = {
html: "<body>This is an example jsfiddle</body>",
js: 'console.log("Example JS!")',
css: "body { font-family: Helvetica, Arial, sans-serif; }",
link: "http://netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css",
script: "http://code.jquery.com/jquery-1.11.1.min.js",
title: "JSFiddler Sample",
description: "Sample page created via JSFiddler api module",
normalize_css: true,
wrap: "b" /* body */,
dtd: 4,
};
jsfiddler.create(options, function (err, fiddlerUrl) {
if (err) return console.error("Failed to create JS Fiddle", err);
console.log("Created JS Fiddle: ", fiddlerUrl);
});
It will also be super helpful if there's any other way to achieve the goal, thanks a ton in advance!