Skip to main content

Amplify SDK

Install Dependencies

Yarn

yarn add aws-amplify

or

NPM

npm install aws-amplify

Configure App

import Amplify from "aws-amplify";
Amplify.configure({
aws_appsync_graphqlEndpoint: "https://api.fluentc.io/graphql",
aws_appsync_region: "us-east-1",
aws_appsync_authenticationType: "AWS_IAM",
aws_cognito_region: "us-east-1",
aws_cognito_identity_pool_id:
"us-east-1:54625d01-5b1e-42a0-bbaf-79f733fe7e3a",
});

Call API

import { API } from "aws-amplify";

async function fetchContent() {
const environmentID = ""; // Available in the FluentC dashboard
const content = (await API.graphql({
query: `
query MyQuery {
requestContent(environmentID: "${environmentID}", language: "${language}") {
body {
key
value
}
}
}
`,
})) as any;

const formattedData: any = {};
content.data.requestContent.body.forEach((i: any) => {
formattedData[i.key] = i.value;
});
setTranslations(formattedData);
}