![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
phetch is a light wrapper around isomorphic fetch (fetch) that allows request generation via the chaining of methods calls instead of bloating methods with crafting initialization or configuration objects.
phetch
.post('/api/accounts')
.set('Content-Type', 'application/json')
.set('Accept', 'application/json')
.set('Authentication', 'Bearer QWxhZGRpbjpPcGVuU2VzYW1l')
.json({ email: 'john.doe@example.com', password: '********' })
.then((res) => res.json())
.then((json) => console.log(json));
A request is initiated by providing the HTTP method and URL to the exported phetch
function.
const req = phetch('GET', '/api/accounts');
Or by calling one of the decorated methods (get
, put
, post
, patch
, delete
, head
)
on the exported phetch
function with a URL.
const req = phetch.get('/api/accounts');
And executed by providing a callback function to the chainable #then()
method.
req
.then((res) => /* ... */ );
Setting headers on a request can be achieved in three ways, firstly via a call to #header()
.
req
.header('Content-Type', 'application/json');
Next, multiple headers can be set by providing an object of mapped header names to their values
to a call to #headers()
req
.headers({
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authentication': 'Bearer QWxhZGRpbjpPcGVuU2VzYW1l'
});
Lastly, either format of the previous two calls can be provided to the #set()
method.
req
.set('Content-Type', 'application/json');
.set({
'Accept': 'application/json',
'Authentication': 'Bearer QWxhZGRpbjpPcGVuU2VzYW1l'
})
Querystrings can be passed along with GET
requests two ways, firstly via a call to #query()
with key an value.
req
.query('email', 'john.doe@example.com'); // api/accounts?email=john.doe%40xample.com
Or by providing an object of mapped parameters to values.
req
.query({
email: 'john.doe@example.com',
firstName: 'John',
lastName: 'Doe'
});
A body can be provided to send along with the request via the #form()
(accepted a DOM node
pointing to a HTML form), or a javascript object via the #json()
method.
req
.form(document.querySelector('.create-account-form'));
// OR ...
req.
.json({ email: 'john.doe@example.com', password: '********' });
#mode()
Sets the mode you want to use for the request, e.g., cors
, no-cors
, or same-origin
.
#credentials()
Sets the request credentials you want to use for the request, e.g., omit
, same-origin
, or
include
.
#cache()
Sets the cache mode you want to use for the request, e.g., default
, no-store
,
reload
, no-cache
, force-cache
, or only-if-cached
.
#redirect()
Sets the redirect mode to use, e.g., follow
, error
, or manual
.
#referrer()
Sets the referrer to send with the request, specifying no-referrer
, client
, or a URL.
#integrity()
Sets the subresource integrity value of the request, e.g.,
sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=
.
The MIT License (MIT)
Copyright (c) 2016 Chuck Preslar
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Chainable wrapper for isomorphic fetch.
We found that phetch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.