We will update the api-post.js to add a create method to make a fetch call to the create API.
mern-social/client/post/api-post.js:
const create = (params, credentials, post) => { return fetch('/api/posts/new/'+ params.userId, { method: 'POST', headers: { 'Accept': 'application/json', 'Authorization': 'Bearer ' + credentials.t }, body: post }).then((response) => { return response.json() }).catch((err) => { console.log(err) })}
This method, like the user edit fetch, will send a multipart form submission using a FormData object that can contain the text field and the image file.