It's time to create an HTTP PATCH method. Follow these steps to create the patchHttp function:
- Create a constant called patchHttp.
- 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 'patch' 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 patchHttp = async (
url,
body,
type = 'json',
options,
) => (await baseHttp(url,
'patch',
{
body,
...