wispy-oliveW
Refine2y ago
7 replies
wispy-olive

useModalForm appends [object Object] onto my endpoint

So I'm trying to pop up an "Edit User" modal on my web app when the user clicks on their avatar in the top right. The only issue is that I'm relying on useModalForm() to make an API call, but it is continuously appending
[object Object]
to my endpoint.

So here's the call from the useModalForm():
    console.log(userId, userId?.data, userId?.data.id, isError, isLoading, typeof(userId?.data.id));
    // const dynamoId : string = userId?.data?.id || "failed-call"
    // console.log("Constructed Resource URL:", `${RESOURCES.USERS}/some-tenant/some-org/${dynamoId}`);
    const {
        modalProps: editUserModalProps,
        formProps: editUserFormProps,
        show: editUserShow,
    } = useModalForm<IUser>({
        action: API_ACTIONS.EDIT,
        warnWhenUnsavedChanges: true,
        resource: `${RESOURCES.USERS}/some-tenant/some-org`,
        id: userId?.data.id
    });


The top line's console.log returns this:
userId = Object { data: {…} }
userId?.data = Object { id: "2811c1ac-e118-4eb8-b2b6-25f541614178", username: "6e671cbb-a206-4a05-ae2a-1afea5af2f14" }
userId?.data.id = 2811c1ac-e118-4eb8-b2b6-25f541614178 
isError = false 
isLoading = false 
typeof(userId?.data.id) = string


This is the URL the front end tries to call as a result:
GET https://3sagmc8ygj.execute-api.us-east-2.amazonaws.com/staging/api/users/some-tenant/some-org/[object%20Object]

Here's how I'm calling that modalForm:

                    <Space size="middle">
                    {/* TODO: () => editUserShow() not working?? */}
                        <div onClick={editUserShow}>  
                            {user?.avatar && (
                                <Avatar
                                    shape="square"
                                    src={user?.avatar}
                                    alt={user?.name}
                                />
                            )}
                        </div>
                    </Space>
Was this page helpful?