Simple render with node.js and no libraries dependencies.
Template
https://mockupsjar.com/mockups/rustic-frame
Input image
https://dummyimage.com/400x600/4697c2/fff.jpg
https://dummyimage.com/400x600/4697c2/fff
Render output
Code sample
const https = require('https')
const API_URL = process.env.API_URL // <https://api.mockupsjar.com>
const API_TOKEN = process.env.API_TOKEN // Put your API TOKEN in here
// template: <https://mockupsjar.com/mockups/rustic-frame>
const url = '<https://api.mockupsjar.com/mockups/render/rustic-frame>'
const postData = JSON.stringify({
zoomLevel: 1,
format: 'jpg',
input: ['<https://dummyimage.com/400x600/4697c2/fff.jpg>']
})
const options = {
method: 'POST',
headers: {
Authorization: 'Bearer ' + API_TOKEN,
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(postData)
}
}
console.log('mockupsjar - simple node render')
let req = https.request(url, options, (res) => {
console.log('statusCode:', res.statusCode)
res.on('data', (d) => {
process.stdout.write(d)
})
})
req.on('error', (e) => {
console.error(e)
})
req.write(postData)
req.end()
Response
statusCode: 200
{
"status":"success",
"data":{
"slug":"rustic-frame",
"name":"Rustic Frame",
"status":"successful",
"zoomLevel":1,
"format":"jpg",
"result":{
"url":"<https://mockupsjar-production.s3-eu-west-1.amazonaws.com/renders/mockup-jyOuSKo5B5k4tarA.jpg>",
"previewUrl":"<https://mockupsjar-production.s3-eu-west-1.amazonaws.com/renders/C95KWij2zEb5xM4k-9XYmfzHecuUusOmM.jpg>"
}
}
}