I use react for frontend.
I get an mp4 video file from an axios call:
const onGetVideo = () => {
axiosClient.get(`/solution/video.mp4`)
.then(({ data }) => {
console.log(data)
// data here is simple binary data
})
.catch(err => {
console.log(err)
})
}
How can I use the response (data) to display the video on the website?
2
Answers
I have found this solution:
We have to specify responseType: 'blob' to get binary data.
When the data is received, we create a Blob URL using URL.createObjectURL(data) and set it as the video source.
could you share the format of the data "response"
if you data response is, in this format then,
data = [{video_url: ""}]
then try this,
const video = data[0].video_url // (here your video url is stored ini the video variable)
install: npm install react-player
add this line in your file : import ReactPlayer from ‘react-player’
add this code:
Try using the above code. This should solve your Question
Happy Coding!!