1

I'm looking to post a static default photo image in my asset folder to my endpoint if no image was uploaded to the input fileuploader. How do you send that through the body. I tried to send the import variable for it but upon getting the image it wasn't correct. Whats the correct way to go about this?

import DefaultPic from '../../../assets/avatars/default.png';

 axios.post(process.env.REACT_APP_HOST + process.env.REACT_APP_PORT + '/users', 

             {
              firstName: this.state.firstName,
              lastName: this.state.lastName,
              image : DefaultPic
            }
          )

Emile Bergeron
  • 17,074
  • 5
  • 83
  • 129
scotth527
  • 77
  • 2
  • 10
  • I guess what I am trying to ask is how to turn the import into a file object since if someone doesn't select an image how do I convert the file in my assets folder into what I will send. When I do type DefaultPic it's just a string. – scotth527 Aug 20 '19 at 12:37

0 Answers0