Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

axios put api in componentDidMount React

componentDidMount() {
    // Simple PUT request with a JSON body using axios
    const article = { title: 'React PUT Request Example' };
    axios.put('https://reqres.in/api/articles/1', article)
        .then(response => this.setState({ updatedAt: response.data.updatedAt }));
}
Source by jasonwatmore.com #
 
PREVIOUS NEXT
Tagged: #axios #put #api #componentDidMount #React
ADD COMMENT
Topic
Name
8+8 =