April 2020
Intermediate to advanced
716 pages
18h 55m
English
In the frontend, to make a request to this create API, we will set up a fetch method on the client side to make a POST request to the API route and pass it the multipart form data containing details of the new shop. This fetch method will be defined as follows:
mern-marketplace/client/shop/api-shop.js:
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))}
We will use this method in the create new shop form view, implemented in the next section, to send the user-entered ...
Read now
Unlock full access