Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react axios POST using async await method with super constructor parent class

export default class PersonList extends React.Component {
    constructor(props) {
        super(props)
    this.state = {
       articleId: null
            };
                }
   async componentDidMount() {
        const article = {title: 'Reac Post Request Example'};
            const res = await axios.post('https://reqres.in/api/articles', article);
       
                this.setState({ articleId : res.data.id });
            }
            
    render()
    {
        const {articleId} = this.state;
        return(
            <div className="card text-center m-3">
                <h5 className="card-header">Simple POST Request</h5>
                <div className="card-body">Returned Id: {articleId}</div> 
            </div>
         

        )
    }
}

Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript prevent right click 
Javascript :: (node:3644) UnhandledPromiseRejectionWarning: TypeError [EMOJI_TYPE]: Emoji must be a string or GuildEmoji/ReactionEmoji 
Javascript :: if operator ternary 
Javascript :: how to remove letters from an array javascript 
Javascript :: remove unused css and js wordpress 
Javascript :: how to set image width and height dynamically in javascript 
Javascript :: jest mock call 
Javascript :: javascript getter 
Javascript :: onclick remove textarea value 
Javascript :: find saturday with moment js 
Javascript :: Using a decrementing For Loop to Reverse an Array 
Javascript :: string js 
Javascript :: query selector 
Javascript :: custom search filter in angular 8 
Javascript :: change dictionary value in React js 
Javascript :: crud in nodejs sequilize 
Javascript :: array push 
Javascript :: react js require pasword to have special charaacter 
Javascript :: Add Multilanguage Support to React App 
Javascript :: .tolowercase 
Javascript :: moyenne javascript 
Javascript :: How to get a range numbers from given numbers in javascript 
Javascript :: mongoose search query for a word in a field 
Javascript :: create expo project with a specific expo SDK 
Javascript :: responsive font size react native 
Javascript :: if text is present make div hide 
Javascript :: js remove english word from string 
Javascript :: first unique character in a string javascript 
Javascript :: pop-under window before current page 
Javascript :: javascript submit form VUE 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =