Skip to content

Instantly share code, notes, and snippets.

@mscoutermarsh
Last active January 10, 2021 23:49
Show Gist options
  • Save mscoutermarsh/69e13b05075123aaf1d6064a3bb14133 to your computer and use it in GitHub Desktop.
Save mscoutermarsh/69e13b05075123aaf1d6064a3bb14133 to your computer and use it in GitHub Desktop.
nodejs convert html/css to image
var request = require('request');
// Retrieve your user id and api key from the Dashboard https://htmlcsstoimage.com/dashboard
var auth = { user: "user_id", pass: "api_key" };
var html = "<div class='ping'>Pong ✅</div>";
var css = ".ping { padding: 20px; font-family: 'sans-serif'; }";
var data = { html: html, css: css };
request.post({ url: 'https://hcti.io/v1/image', form: data, auth: auth }, function(err, httpResponse, body) {
console.log(body);
});
// {"url": "https://hcti.io/v1/image/bde7d5bf-f7bb-49d9-b931-74e5512b8738"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment