1

I'm trying to display image from public folder of my node api directory. I want to display image in front end vue file. I don't know how to give source of image.

This is the directory. I want to display image nodelogin.png

This is the directory. I want to display image nodelogin.png

I want to display these images.

    <img :src="myimage" alt="Logo" width="80" height="80" />

This is my template code.

     async created() {
             this.myimage = await this.getImage();
         },
     methods: {
             async getImage(){
                 return await 'http://localhost:4000/api/public/nodelogin.png';
             }
          }

But this code gives an error response. Cannot GET /api/public/nodelogin.png Actually I'm new to node and Vue So I'm not sure whether my logic is correct or not.

Do I need to do something from my backend side?

4
  • 1
    what's the error ? Commented Jan 3, 2022 at 7:42
  • Cannot GET /api/public/nodelogin.png Commented Jan 3, 2022 at 7:57
  • does <img src="http://localhost:4000/api/public/nodelogin.png" alt="Logo" width="80" height="80" /> work? Commented Jan 3, 2022 at 8:22
  • No, not working. Cannot GET /api/public/nodelogin.png Commented Jan 3, 2022 at 8:50

2 Answers 2

1

Just use the url '/nodelogin.png'

Sign up to request clarification or add additional context in comments.

1 Comment

also you dont need to the getImage() method
0

Thanks for your question posting.

If you want see png, you should input url :

http://localhost:4000/nodelogin.png

Good luck for your business.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.