Helper Functions
Preparing Init
The following functions will initialize the RequestInit object for specific use-cases.
All of them will setcredentials to "include" and a header Accept with value of "application/json"
prepareGetprepares a GET requestpreparePost/Patch/Put/Deleteprepares a form-data POST/PATCH/PUT/DELETE request.preparePostUrlEncodedprepares a form url-encoded POST requestprepareFormDataPostprepares a POST request with aFormDataobject and detects if it contains files.- if it contains files, it will call
preparePostand set the body to the formData object. - otherwise
preparePostUrlEncodedwill be called and the properties of the formData will be set accordingly.
- if it contains files, it will call
You don't need to use them. You can write your own code to initialize the RequestInit object. These are just here for convenience.