{"size": 1455, "ext": "js", "max_stars_repo_path": "src/user/apiuser.js", "max_stars_repo_name": "Harishkumar01/StickyNotesFront", "max_stars_repo_stars_event_min_datetime": "2021-09-04T03:59:36.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-04T03:59:36.000Z", "max_issues_repo_path": "src/user/apiuser.js", "max_issues_repo_name": "Harishkumar01/StickyNotesFront", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/user/apiuser.js", "max_forks_repo_name": "Harishkumar01/StickyNotesFront", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.4545454545, "max_line_length": 68, "alphanum_fraction": 0.5326460481}
export const read = (userId,token) => {
    return fetch(`${process.env.REACT_APP_API_URL}/user/${userId}`,{
        method: "GET",
        headers: {
            Accept: "application/json",
            "Content-Type": "application/json",
            Authorization: `Bearer ${token}`
        }
    })
    .then(response => {
        return response.json()
    })
    .catch(err => console.log(err));
}

export const update = (userId,token,user) => {
    console.log("USER DATA UPDATE: ", user)
    return fetch(`${process.env.REACT_APP_API_URL}/user/${userId}`,{
        method: "PUT",
        headers: {
            Accept: "application/json",
            Authorization: `Bearer ${token}`
        },
        body: user
    })
    .then(response => {
        return response.json()
    })
    .catch(err => console.log(err));
}

export const remove = (userId,token) => {
    return fetch(`${process.env.REACT_APP_API_URL}/user/${userId}`,{
        method: "DELETE",
        headers: {
            Accept: "application/json",
            "Content-Type": "application/json",
            Authorization: `Bearer ${token}`
        }
    })
    .then(response => {
        return response.json()
    })
    .catch(err => console.log(err));
}

export const List = () => {
    return fetch(`${process.env.REACT_APP_API_URL}/users`,{
        method: "GET",
    })
    .then(response => {
        return response.json()
    })
    .catch(err => console.log(err));
}