• Kshitij Gundale
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
var url = 'https://cunning-wolf-lr1avv-dev-ed--c.documentforce.com/servlet/rtaImage?eid=0012w00000Kou4b&feoid=00N2w00000FPu0u&refid=0EM2w000001JN20'

const request = https.get(url, response => {
  console.log(response.statusCode)
  if(response.statusCode === 200){

      let chunks = [];

      response.on('data', chunk => {
          chunks.push(chunk)
      }).on('end', () => {
          const buffer = Buffer.concat(chunks)
          const imageId = book.addImage({
              buffer: buffer,
              extension: 'jpg',
          });

          sheet.addImage(imageId, {
              tl: { col: 0, row: 0 },
          });
      })
  }

I want to get the image in base64 encoding from url in the code. The problem is I get statuscode 302 everytime I run the code. Is there any other way to get the image using node.js?