Returning Promise in a function

Hi guys, Today I will show you how can you return a promise in the function. Let see an example
function testPromise() {
  return new Promise( function(resolve, reject) {
    resolve("Test Result");
  });
}

testPromise.then(function(d){
  console.log(d);
});
It will give an error TypeError: testPromise.then is not a function the issue is that the function doesn't have a then property, but the promise it returns does. so correct answer will be,
function testPromise() {
  return new Promise( function(resolve, reject) {
    resolve("Test Result");
  });
}

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() {

Pages