Fetch the create API in the view

In the frontend, to use this create API, we will set up a fetch method in client/shop/api-shop.js to make a post request to the create API by passing the multipart form data:

const create = (params, credentials, shop) => {  return fetch('/api/shops/by/'+ params.userId, {      method: 'POST',      headers: {        'Accept': 'application/json',        'Authorization': 'Bearer ' + credentials.t      },      body: shop    })    .then((response) => {      return response.json()    }).catch((err) => console.log(err))}

Get Full-Stack React Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.