Giter VIP home page Giter VIP logo

Comments (6)

ttiras avatar ttiras commented on July 20, 2024 1

thank you renanbastos93,
actually there is no space in the urls but i will look into it.
apparently the issue is not related to image-to-base64.

from image-to-base64.

renanbastos93 avatar renanbastos93 commented on July 20, 2024

your error way line /usr/src/app/handlers/emails.js:87:33
Can you show name uses? Please, post here code from example.

from image-to-base64.

ttiras avatar ttiras commented on July 20, 2024

const items = order_items.map(async item=>{
const price = (item.product.price - (item.product.price*item.product.discount/100))
const image = https://backend.rover.micota.com.tr/build/img/${item.product.image[0].path}.jpeg

    const decodedImage = await imageToBase64(image)
      
    return (
     `<div style="border-style: solid">
     <img style="width:150px" src="data:image/jpg;base64,${decodedImage}">            
      <p><span>${item.product.name}</span></p>
      <p><span>${item.qty} Adet</span></p>
      <p><span>${price} TL</span></p>
      </div>`
    )                 
  })

item.product.image[0].path = "Supla_Beyaz1"

from image-to-base64.

renanbastos93 avatar renanbastos93 commented on July 20, 2024

I tested it and worked well, but I made a code a little different.
Why I change it? because I see one point

you don't treat item.product.image length

var order_items = [
    {
        product: {
            name: "test",
            price: 1,
            discount: 0,
            image: [{
                path: "Supla_Beyaz1"
            }]
        },
        qty: 1
    }
]

let items = order_items.map(async item=>{
    let price = (item.product.price - (item.product.price*item.product.discount/100))
    let image = "";
    let decodedImage = "";

    if (item.product.image.length > 0 && item.product.image[0].path) {
        image = `https://backend.rover.micota.com.tr/build/img/${item.product.image[0].path}.jpeg`
    }

    decodedImage = await imageToBase64(image)
        
    return `<div style="border-style: solid">
        <img style="width:150px" src="data:image/jpg;base64,${decodedImage}">            
        <p><span>${item.product.name}</span></p>
        <p><span>${item.qty} Adet</span></p>
        <p><span>${price} TL</span></p>
    </div>`
})

Output:
image

from image-to-base64.

ttiras avatar ttiras commented on July 20, 2024

thank you very much.
you are right, but i am sure that image is there because this endpoint is only posted with a product being present and every product has an image.
so your code doesn't make a difference. my code worked for months, it only gave this error this morning and now it is working again and i don't know what happened and how it started working again.

now i am afraid if it is going to give this error again in the future: code: 'ERR_UNESCAPED_CHARACTERS'
do you know what is this error about?

from image-to-base64.

renanbastos93 avatar renanbastos93 commented on July 20, 2024

@ttiras

wow, so this problem ERR_UNESCAPED_CHARACTERS normally raises when to try request a URL with spaces then you must escape it or unsupported file extension.

https://nodejs.org/api/errors.html#errors_err_unescaped_characters

from image-to-base64.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.