'React Chat Engine Loading

I create small chat application using react chat engine library. This is the UI image

enter image description here

But chats are not loading even I provide correct credentials. It's gives GET https://api.chatengine.io/chats/latest/25/ 403.There is no any error of code side. I used Firebase authentication for get logged user details. Using Auth context set user details. Those process are work correctly. I have no idea about this issue.

    import React,{useRef,useEffect,useState} from "react";
    import { useHistory } from "react-router-dom";
    import {ChatEngine} from 'react-chat-engine';
    import { auth } from "../firebase";

    import {useAuth} from '../contexts/AuthContext';
    import axios from "axios";

    const Chats = () => {

        const history = useHistory();
        const {user}= useAuth();
        const[loading,setLoading]=useState(true);

        const getFile =async (url) =>{
            const response = await fetch(url);
            const data =await response.blob();

            return new File([data],"userPhoto.jpg",{type:"image/jpeg"})
        }
        
      useEffect(()=>{
        if(!user){
            history.push('/')
            return;
        }
        axios.get('https://api.chatengine.io/users/me',{
            headers:{
                "project-id":"8dc9fa0e-7ed4-40ec-a003-a7c76a11e7f7",
                "user-name":user.email,
                "user-secret":user.uid
            }
        })
        .then(()=>{
           setLoading(false);
        })
        .catch(()=>{
            let formdata=new FormData();
            formdata.append('email',user.email);
            formdata.append('username',user.email);
            formdata.append('secret',user.uid);

            getFile(user.photoURL)
            .then((avatar)=>{
                formdata.append('avatar',avatar,avatar.name)

                axios.post('https://api.chatengine.io/users/',
                formdata,
                {headers:{"private-key":"1445fb04-f7c9-42d2-b63b-3019a881d3a3"}}
                ).then(()=>setLoading(false))
                .catch(error => console.log(error))
            })
        })
      },[user,history])

        const LogoutHandler =async()=>{
           await auth.signOut();
            history.push('/');
        }

        if(!user || loading) return 'Loading ...';

      return (
        <div className="chat-page">
          <div className="nav-bar">
            <div className="logo-tab">UEassyMessage</div>
            <div className="logout-tab" onClick={LogoutHandler}>Logout</div>
          </div>
        <ChatEngine
            height="calc(100vh-66px)"
            projectID= '8dc9fa0e-7ed4-40ec-a003-a7c76a11e7f7'
            userName={user.email}
            userScret={user.uid}
        />
        </div>
      );
    };

    export default Chats;

Can anyone have idea about this issue?



Solution 1:[1]

Not sure if you still have this problem, but it should be userSecret instead of userScret. I had the same problem cause I write projectID with a lower case d.

Solution 2:[2]

I think you have a space in your projectID={} prop which is likely problematic. Make sure you take that away and try again.

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 MeoW
Solution 2 Adam LaMorre