DEV Community

Ashish donga
Ashish donga

Posted on

How to call multiple time amplify query in react JS

How to call multiple time amplify query in react JS

How To Use The Same GraphQL Query Multiple Times In A Single API Call. Amplify, DynamoDB

const response = await Promise.all(
            signupData.educationalDetails.map(async (item) => {

            console.log("item",item)

            const variables = {
                studentId: newTodo?.data?.createStudent?.id,
                examPassed: item?.data?.boardType,
                boardName: item?.data?.boardName,
                passingYear: item?.data?.boardYear,
                percentage: item?.data?.boardPercentage,
                resumeUrl: item?.data?.boardFile
            }
            console.log("variables", variables)

            try{
            const newTodo2 = await API.graphql({ query: mutations.createEducational, variables: { input: variables } });
            }catch(e){
                console.log("####",e)
            }
            console.log('newTodo2Demo', { query: mutations.createEducational, variables: { input: variables } })

            return{
                boardName: item?.data?.boardName
            }

            // console.log('newTodo2Demo', newTodo2)

        })
        )
Enter fullscreen mode Exit fullscreen mode

thank you for reading How to call multiple time amplify query in react JS

Top comments (0)