Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react native extract cookie from response

// 'headers' is iterable
const get_set_cookies = function(headers) {
    const set_cookies = []
    for (const [name, value] of headers) {
        if (name === "set-cookie") {
            set_cookies.push(value)
        }
    }
    return set_cookies
}

fetch(url, {
    method: "POST",
    credentials: "same-origin", // or 'include' depending on CORS
    // ...
})
.then(response => {
    const set_cookies = get_set_cookies(response.headers)
})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #react #native #extract #cookie #response
ADD COMMENT
Topic
Name
3+8 =