In api-media.js, we will add a corresponding method to make a POST request to the create API by passing the multipart form data from the view.
mern-mediastream/client/user/api-user.js:
const create = (params, credentials, media) => { return fetch('/api/media/new/'+ params.userId, { method: 'POST', headers: { 'Accept': 'application/json', 'Authorization': 'Bearer ' + credentials.t }, body: media }).then((response) => { return response.json() }).catch((err) => { console.log(err) }) }
This create fetch method will be used when the user submits the new media form to upload a new video.