Closed charliev closed 9 years ago
Hi, can you real quick post fuller code that I can run and what version of this module you are using, please? For example, code code necessary for me to create "accept" variable to run your code above.
Weird, It must be something I'm doing wrong, this is what my code is basically doing:
var accepts = require('accepts');
function test(headers) {
var accept = accepts({
headers: headers
});
switch(accept.types('html', 'json')) {
case 'html':
console.log('html');
break;
case 'json':
console.log('json');
break;
default:
console.log('not acceptable');
}
}
test({});
test({
accept: 'application/json'
});
test({
accept: 'text/plain'
});
test({
accept: 'foo/bar'
});
but it works fine, should've tested that first. I desperately need some sleep now, will look at it over the weekend. Close at will; sorry to have bothered you. k.
my bad: I had an infinite recursion in the default case
It's no problem. I'm glad you figured it out :)
Hi,
I am getting this
RangeError: Maximum call stack size exceeded
when testing with non-existent accept-headers. that is:I tried
to get around the problem, but it still crashes the process I haven't tried to pimp the request.headers yet, I don't know if it can be done but it looks like it shouldn't
k.