Hi I'm building a video uploader and right now I can upload video from my front-end (React.js) to my back-end public folder (Node.js) using POST method (ajax). I was wondering how to now send it back to the front-end and get the videos to play. Thought of doing a GET method route of my back-end, could that work? (Have to say I'm a bit confused on this part since I'm only used to doing HTTP request from front to back...)
Would much appreciate any good advice to point me to the right direction. Thanks!
If you're saving the uploaded videos to a folder on your server, you could add something like this to your app:
app.get(__dirname + '/uploads/:vid', function(req, res){
res.sendFile(req.url);
});
Then you would simply send a regular GET request from your front-end to the path of the video (which will trigger the above function) and you should get the requested video in the response.