chatengine-io / react-chat-engine-advanced

Chat Engine's react components done the right way...
MIT License
18 stars 11 forks source link

Add Avatar Image on Sign Up #208

Open HelenGezahegn opened 11 months ago

HelenGezahegn commented 11 months ago

Problem When creating a new user and calling the https://api.chatengine.io/users/ api, I want to send in the avatar image. I've tried to send it as avatar (sends an error) and avatarUrl (no error but avatar image not updated), but it doesn't get set.

This is my current API call:

outer.post("/signUp", async (req, res) => {
  try {
    const { username, password, avatar } = req.body;

    const chatEngineResponse = await axios.post(
      "https://api.chatengine.io/users/",
      {
        username: username,
        secret: password,
        avatarUrl: avatar // How do I pass in the avatar image url properly?
      },
      {
        headers: { "Private-Key": process.env.PRIVATE_KEY }
      }
    );

    res.status(200).json({ response: chatEngineResponse.data });
  } catch (error) {
    console.error("Error", error.message);
    res.status(500).json({ error: error.message });
  }
});

Question How do I pass in the avatar image url properly?