Releases: Legitcode/legible
Releases · Legitcode/legible
Release list
0.2.11
0.2.10
Block requests by returning false from a url function, heres the use case!
You can globally prevent duplicating requests within the same time period.
let lastUrl;
const onURL = url => {
//block repeat requests within a second of each other
if (url === lastUrl) return false;
lastUrl = url;
setTimeout(() => lastUrl = '', 1000);
return url
};
let response = await partial`
url: ${onURL}
`;
//request was made multiple times in a second, return false!
if(response.requestBlocked) return false0.2.9
Cancel rest of request after headers are sent back, ex on a 401 redirect
await request`
url: https://freegeoip.net/json/github.com
onResponse: ${response => {
expect(response.headers.get('content-type')).to.equal('application/json')
return true
}}
`
0.2.8
0.2.7
0.2.6
01bda82
Fix bug when merging partial to empty HTTP method
119c307
fix bug merging body
Header callback, allows you to do this:
let response = await partial`
url: https://google.com
headers: ${partial => {
if(partial.options.method === 'POST') return {...headers, 'Content-Type': 'application/json' }
return headers
}}
`