Now we are creating an HTTP PUT method. Use the following steps to create the putHttp function:
- Create a constant called putHttp.
- 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 'put' 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 argument 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 putHttp = async (
url,
body,
type = 'json',
options,
) => (await baseHttp(url,
'put',
{
body,
...options...