In this section, we are creating an HTTP UPDATE method. Follow these steps to create the updateHttp function:
- Create a constant called updateHttp.
- Assign to that constant an asynchronous function that receives four arguments, url, body, type, and options. The type argument will have the default value of 'json'.
- In this function return, we will execute the baseHttp function, passing the url that we received, and 'update' as the second argument. In the third argument, we will pass an object with the body variable, and the deconstructed options argument that we received. Because of the currying property of baseHttp, we will execute the returned function with the type we received. body is usually a JSON or a JavaScript object, but if this request is going to be a file upload, body needs to be a FormData object:
export const updateHttp = async (
url,
body,
type = 'json',
options,
) => (await baseHttp(url,
'update',
{
...