lquixada / cross-fetch

Universal WHATWG Fetch API for Node, Browsers and React Native.
MIT License
1.67k stars 104 forks source link

incorrect response when using: response.text() #83

Closed dearfrankg closed 3 years ago

dearfrankg commented 3 years ago

I'm getting an incorrect response when using: response.text()

More details and script here: https://hastebin.com/feloheweve.http

CORRECT TEXT RESPONSE using postman

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://InspectionService/">
    <SOAP-ENV:Body>
        <ns1:GetRequestResponse>
            <RequestResponseResult>
                <success>true</success>
                <status>closed</status>
                <state>7</state>
                <message>Inspection Request Complete</message>
                <report>https://oneguardinspections.com/components/com_rstickets/files/2020/12/22/PRCO18/PRCO-0000000018_PDF_Report.pdf</report>
            </RequestResponseResult>
        </ns1:GetRequestResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

ACTUAL TEXT RESPONSE from response.text()

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ns1="http://InspectionService/">
    <SOAP-ENV:Body>
        <ns1:GetRequestResponse>
            <RequestResponseResult>
                <success>true</success>
                <status/>
                <state/>
                <message/>
                <report/>
            </RequestResponseResult>
        </ns1:GetRequestResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
lquixada commented 3 years ago

@dearfrankg can you try doing the same thing with node-fetch? This is what cross-fetch uses behind the scenes for node environments.

dearfrankg commented 3 years ago

Same problem with node-fetch.
I will post the issue on their module page.
Feel free to add any comments if you ave any.

// global.fetch = require("cross-fetch");
global.fetch = require("node-fetch");
lquixada commented 3 years ago

Thanks @dearfrankg ! closing this for now.