Writing Custom Callback for ajax

In this post, I will share how could you use callbacks to write efficient and maintainable ajax using callbacks. Promises can also be use but here i will discuss it with callbacks.
The definition of callback is
A reference to executable code, or a piece of executable code, that is passed as an argument to other code. 
Let's see an example code of custom callback,
function test(param1, param2, callback) {
    alert('Started function.\n\nIt has: ' + param1 + ', ' + param2);
    callback();
}
test('foo', 'bar', function() {
    alert('Finished function.');
});

Ajax in React

Today I will share you the example that how ajax call can be done in react. You can choose any HTTP library but i will choose the axios. Here is the example this code will take reddit aww subreddit text and images from subreddt aww(cute pictures of animals). Here is the following code
import React from 'react';
import ReactDOM from 'react-dom';
import axios from 'axios';

class AjaxDemo extends React.Component {
    constructor(props) {
        super(props);

        this.state = {
            posts: []
        };
    }

    componentDidMount() {