katylava
4/22/2016 - 4:48 PM

testLabelary.js

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

request.post({ body: "^xa^cfa,50^fo100,100^fdHello World^fs^xz", encoding: null, url: 'http://api.labelary.com/v1/printers/8dpmm/labels/4x6.75/0/' }, function(err, resp, body) {
    if (err) {
        return console.log(err);
    }

    console.log('headers', resp.headers);
    console.log('status', resp.statusCode);
    console.log('body', body);

    if (body.length < 1000) {
        console.log(new Buffer(body).toString());
    }

    fs.writeFile('./label.png', body, function(err) {
        if (err) {
            console.log(err);
        }
    });
});