'OpenApi generated typescript not properly calling api from React Webapp

I have a react webapp and a spring boot java backend api. The backend Api works perfectly fine with postman.

In the react webapp, I am using openapi generated typescript to make the calls to the backend api. I have two parameters for the api, a number and an object. The object is just json style object.

When I use the typescript to call the api, for some reason, it passes in null for the object parameter and the api returns a 500 error. I have no clue why this is happening. Any suggestions? Here is the code where I call the api:

function gatherUserData(){
    const UserDataRetval: UserData = {};
    UserDataRetval.version = kVersion;
    UserDataRetval.Methods = [];
    if (checkedLikesYouCount){
        UserDataRetval.Methods.push(UserDataMethodsEnum.RECOM_LIKES_YOU_COUNT)
    }
    if (checkedRecosRecommendations){
        UserDataRetval.Methods.push(UserDataMethodsEnum.RECOS_RECOMMENDATIONS)
    }
    if (checkedUsersRecommendations){
        UserDataRetval.Methods.push(UserDataMethodsEnum.USERS_RECOMMENDATIONS)
    }
    if (checkedProfileUser){
        UserDataRetval.Methods.push(UserDataMethodsEnum.PROFILE_USERID)
    }
    if (checkedProfile){
        UserDataRetval.Methods.push(UserDataMethodsEnum.PROFILE)
    }
    if (checkedRecosLikesYou){
        UserDataRetval.Methods.push(UserDataMethodsEnum.RECOS_LIKES_YOU)
    }
    if (checkedRecommendationsLikesYou){
        UserDataRetval.Methods.push(UserDataMethodsEnum.RECOM_LIKES_YOU)
    }
    return UserDataRetval;
}


//USER CLICKS SUBMIT BUTTON, CHECKS USERID ISNT EMPTY, BRINGS UP JSON DATA
function handleSubmit() {
  console.log("Call API for methods:")
  console.log(userid)
  SetDisplayJson(userid !== "")
    auth.onAuthStateChanged(user => {
        if (user) {
            user.getIdTokenResult(false)
                .then(tokenResult => {
                    console.log("token: ", tokenResult.token)
                        new ServiceApi(headerConfig(tokenResult.token)).simulateUser(parseInt(userid), gatherUserData()).then((response) => {
                            console.log(response);
                        }, (error) => {
                            console.log(error);
                        })

                }).catch(e => console.log(e))
        }
    })
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source