Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Request failed with status code 400 #972

Closed
tbaustin opened this issue Jun 24, 2017 · 3 comments
Closed

Error: Request failed with status code 400 #972

tbaustin opened this issue Jun 24, 2017 · 3 comments

Comments

@tbaustin
Copy link

I am using axios and trying to post to localhost:3000/posts and getting this error above. Here is the code:

import axios from 'axios';
import {
  GET_ALL_POSTS,
  GET_POST,
  CREATE_POST,
  DELETE_POST,
  UPDATE_POST
} from './types';

const ROOT_URL = 'http://localhost:3000';

export function createPost({content, title}, cb) {
  return function(dispatch) {
    axios.post(`${ROOT_URL}/posts`, {content, title})
      .then((response) => {
        console.log(response);
        dispatch({
          type: CREATE_POST,
          payload: response
        });
      })
      .then(() => cb())
      .catch((error) => {
        if(error.response) {
          console.log(error.response);
        }
        console.log("Problem submitting New Post", error);
      });
  }
}
@mentos1386
Copy link

Hey,
Request failed with status code 400 means that request was created, but server returned response with HTTP code 400 (Bad Request).

@rubennorte
Copy link
Member

I'm closing this PR as it doesn't seem an issue in Axios but in your web server.

@csr15
Copy link

csr15 commented Mar 22, 2020

User redux thunk(Middleware) where you can apply asynchronous logics

@axios axios locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants