Image Upload Code Sample - JavaScript with Request
Image Upload Sample Code - JavaScript with Request
The code below is using the request
library to simplify handling of the HTTP request.
const fs = require('fs')
const request = require('request')
var url =
'https://<<domain_prefix>>.retail.lightspeed.app/api/2.0/products/{product_id}/actions/image_upload'
var options = {
method: 'POST',
uri: url,
formData: {
image: fs.createReadStream('{file_path}')
},
headers: {
Authorization: 'Bearer {token}',
'Content-Type': 'multipart/form-data'
}
}
request.post(options, function optionalCallback (err, response, body) {
if (err) {
console.log(err)
} else {
console.log(body)
}
})
Updated 7 months ago