[POST 400 error] jquery.js:8630

Why am I getting 400 error (bad request) after creating an instance of RemoteDataStore???

var remoteDS = new App.RemoteDataStore(“http://coffeerun-v2-rest-api.herokuapp.com/api/coffeeorders”);
remoteDS.add(‘a@b.com’, {emailAddress: ‘a@b.com’, coffee: ‘espresso’});

I typed the above lines of code on the console and I keep getting the 400 error message. I have no idea where it went wrong… Can anyone help??

The following is my remotedatastore.js

(function(window) {
  'use strict';
  var App = window.App || {};
  var $ = window.jQuery;

  function RemoteDataStore(url) {
    if (!url) {
      throw new Error('No remote URL supplied.');

    this.serverUrl = url;


  RemoteDataStore.prototype.add = function (key, val) {
    $.post(this.serverUrl, val, function (serverResponse) {
    }); //jQuery의 $.post 메소드를 사용

  App.RemoteDataStore = RemoteDataStore;
  window.App = App;


Hello, were you able to solve this???

I had the same issue. It worked for me when using a complete order object (instead of just two properties), like this:

const remoteDS = new App.RemoteDataStore('http://coffeerun-v2-rest-api.herokuapp.com/api/coffeeorders');
remoteDS.add('a@b.com', {emailAddress: 'a@b.com', coffee: 'espresso', size: 'short', flavor: 'mocha', strength: 15});