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.
Yodel wraps JavaScript's native fetch
API (the new replacement for XMLHTTPRequest) with added model validation.
yodel
accepts the following configuration:
url
: The AJAX endpoint. Query parameters can be included here and/or at request time.request
: Optional overrides for the fetch configuration defaults.transform
: An optional method which can perform arbitrary transformations on validated data.validation
: An object that mirrors the data you expect, with validation rules in place of values.Supported validation types:
yodel
returns an object with the following methods:
get([object] params)
: Performs an HTTP GET request. Supplied params are converted to query string parameters. Returns a promise that resolves with the JSON-parsed response.delete([object] params)
: Same API as get
, but performs an HTTP DELETE.post([FormData] body, [object] params)
: Performs an HTTP POST request. See the fetch post documentation. Supplied params are converted to query string parameters. Returns a promise that resolves with the JSON-parsed response.put([FormData] body, [object] params)
: Same API as post
, but performs an HTTP PUT.const users = yodel({
url: 'http://jsonplaceholder.typicode.com/users',
request: {
mode: 'cors',
cache: 'default'
},
transform: data => {
data.transformed = true;
},
validation: [
{
id: {
type: 'number',
required: true,
min: 1,
max: 10
},
name: {
type: 'string',
required: true,
minLength: 1,
maxLength: 255
},
address: {
street: {
type: 'string',
required: true,
custom: data => {
return true;
}
},
zipcode: {
regex: /\d+/
}
}
}
]
});
users.get().then(data => {
console.log(data);
}).catch(error => {
console.error(error);
});
See the fetch documentation for current browser support and polyfills. Additionally, Yodel uses ES2015, and may require transpilation for browsers other than Chrome and Firefox.
FAQs
Yodel wraps JavaScript's native fetch API with added model validation.
The npm package yodel receives a total of 1 weekly downloads. As such, yodel popularity was classified as not popular.
We found that yodel 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.