Problem recovering data via axios to post a message on my corporate social network please help me thank you

Good evening everyone! Here I am creating a social network and to post a post I would like to retrieve the posterId (the user) to know who is sending a post except that I cannot do it, I would like that when we publish there is the posterId and the user’s message but I cannot recover the posterId and therefore I have a bad request since the posterId is mandatory to post a message, thank you in advance do not hesitate to ask for more code

import './share.css'
import { PermMedia } from "@mui/icons-material"
import { useState } from 'react'
import Axios from 'axios'
import axios from 'axios';


export default function Share() {
    const [publier, setPublier] = useState('')

    const register = () => {
        Axios.post('http://localhost:4200/api/post/', {
         posterId: posterId,
         message: ""
        }).then((response) =>{
          console.log(response)
        })

        let id = axios.get('http://localhost:4200/api/post/')
        const posterId = id.params.posterId
    }


  return (
    <div className='share'>
        <div className="shareTop">
            <img className='shareProfilImg' src="/assets/person/1.jpeg" alt="" />
            <input placeholder='Que veux-tu publier ?' className='shareInput' onChange={(e) => { setPublier(e.target.value) }} />
        </div>
        <hr className='shareHr'/>
        <div className="shareBottom">
            <div className="shareOptions">
                <div className="shareOption">
                    <PermMedia htmlColor='tomato' className='shareIcon' />
                    <span className='shareOptionText'>Photo ou Vidèo</span>
                </div>
                <button className='shareButton' onClick={register}>Publier</button>
            </div>
        </div>
    </div>
  )
}

1 Like