我想获得从帖子返回到有效负载的响应。如何发送返回到操作的结果。我该怎么做?
import axios from 'axios';
import * as types from './actionTypes';
const ROOT_URL = `http://localhost:8000`;
export function addPost(title){
const url = `${ROOT_URL}/api/v1/post/`;
var request;
axios.post(url, {
title: title,
}).then(function (response) {
request = response;
})
.catch(function (response) {
request = response;
});
console.log(request);
return {
type:types.ADD_POST,
payload:request
}
}