I'm working on an API project which communicate with another API, my front is AngularJS. I take back the project, I don't understand the whole of it yet...
Here is my current situation:
I'm on http://localhost:3004/#/references/add/pictures
When I post a picture, it return me the name of the picture hashed with random characters, this is what I want. BUT when picture is posted, it redirects me to the API's URL where the picture is posted which is http://localhost:3000/api/pictures
I would like to stay on my first page and just get the name of my picture to use it in my form.
I identified the lines which sends the picture:
const router = require('express').Router()
// Uploads file to DB
router.post('/', upload.single('file'), (req, res) => {
res.send(res.req.file.filename);
});
I'm not a crack in node.js, just learning, I hope you understand my question which is:
How can I do to post a picture, get the picture name generated (to use it), and stay on my page http://localhost:3004/#/references/add/pictures
?
Thanks for replies