Authorization error

Hi,

I am new to the Amity APIs and I am using @amityco/ts-sdk to develop social features in my ReactNative application.

I have a problem with fetching community posts.

This error sometime (Not Always) returns when I want to fetch:

{"error": [Error: Amity SDK (400100): Authorization info not found], "loading": false, "origin": "server"}

I am calling await connectClient({userId, displayName}); every time that user opens the app.
Also I can get user’s data by liveUser but I don’t know why I am getting the authorization error when I want to fetch community posts.

Hi Tech, before you call await connectClient({userId, displayName});, you need to initialize this code to setup AmityClient first.

import { API_REGIONS, createClient, enableCache } from '@amityco/ts-sdk';

const apiKey = 'YOUR_API_KEY';

const client = createClient(apiKey, API_REGIONS.EU);

enableCache();

For more information, you can check this link from AmityDoc https://docs.amity.co/installation#initialization

2 Likes