Skip to content
Advertisement

How can I bring a HTML Image to the backend?

I have a middleware:

export async function imageTagging(image){
    console.log(image)
    const response = await axios.get('/api/tensorflow', {
        image: image
    });
    return response.data[0];
}

which logs me (image):

<img data-v-713aaf8f="" id="MLIMAGE" src="/img/Erdmännchen.b5f674c2.jpg" width="50%" crossorigin="anonymous" class="card-img-top embed-responsive-item" style="border-style: solid;">

my API-Call in the backend looks like:

 app.get('/api/tensorflow', userMiddleware.isLoggedIn, (req, res) => {
  console.log(req.query);
  console.log(res.query);
})

it logs me:

{}
undefined

Advertisement

Answer

First of all, you are doing a GET request. You can’t post data to a /GET endpoint. You need a /POST.

Secondly, req.query is an object of key-value pairs of query parameters, which in your case is rightfully empty. So I don’t understand, what is your exact question?

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement