In this final step, we will create a DELETE HTTP method. Follow these steps to create the deleteHttp function:
- Create a constant called deleteHttp.
- 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 'delete' 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 deleteHttp = async (
url,
body,
type = 'json',
options,
) => (await baseHttp(url,
'delete',
...