
export function createBasicHeader() : Headers {
    const headers = new Headers();
    //headers.set('Access-Control-Allow-Origin', '*');
    return headers;
}

export function setContentTypeHeaderJson(headers: Headers){
    return headers.set("Content-Type", "application/json");
}

export function setAuthHeader(headers: Headers){
    // retrieve session data from browser storage
    const sessionStr = localStorage.getItem("session");
    let loginResponse = null;
    if(sessionStr){
        loginResponse = JSON.parse(sessionStr);
    }
    // add token if possible
    if(loginResponse && loginResponse.token){
        headers.set("Authorization", "Bearer " + loginResponse.token)
    } else {
        console.log("No access token!")
    }
    return headers;
}