cURLtoSwagger icon indicating copy to clipboard operation
cURLtoSwagger copied to clipboard

Uncaught TypeError: Cannot use 'in' operator to search for 'length'

Open loretoparisi opened this issue 9 years ago • 4 comments

script.js:2003 Uncaught TypeError: Cannot use 'in' operator to search for 'length' 

The error seems to take place at line var length = !!obj && "length" in obj && obj.length, in

function isArrayLike( obj ) {

    // Support: real iOS 8.2 only (not reproducible in simulator)
    // `in` check used to prevent JIT error (gh-2145)
    // hasOwn isn't used here due to false negatives
    // regarding Nodelist length in IE
    var length = !!obj && "length" in obj && obj.length,
        type = jQuery.type( obj );

    if ( type === "function" || jQuery.isWindow( obj ) ) {
        return false;
    }

    return type === "array" || length === 0 ||
        typeof length === "number" && length > 0 && ( length - 1 ) in obj;
}

loretoparisi avatar Aug 06 '16 21:08 loretoparisi

@loretoparisi It is related by third party's source. If you give me a emaple cURL command or response, I'll try to fix it.

goofmint avatar Aug 07 '16 00:08 goofmint

Any update on this?

brandonros avatar Apr 26 '19 17:04 brandonros

@loretoparisi It is related by third party's source. If you give me a emaple cURL command or response, I'll try to fix it.

curl 'https://api.dabapiao.com/front/h5/search/shift-time' -H 'Accept: application/json, text/plain, /' -H 'Referer: https://h5.dabapiao.com/' -H 'Origin: https://h5.dabapiao.com' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36' -H 'DNT: 1' -H 'Content-Type: application/x-www-form-urlencoded' --data 'fromCityId=1&toCityId=2&upStationId=5&downStationId=22&__guestToken=PKEIPPKIXBUTBVDVNPFN&__lang=zh-cn' --compressed

I think it's this part "--data 'fromCityId=1&toCityId=2&upStationId=5&downStationId=22&__guestToken=PKEIPPKIXBUTBVDVNPFN&__lang=zh-cn' " that is triggering this issue

cuipengfei avatar Aug 13 '19 07:08 cuipengfei

Hi I'm having same error on trying to load a Post curl, do you know how to fix or some way to avoid it? thank you

lotogus avatar Sep 15 '22 13:09 lotogus