Ember post request with django rest shows an error


#1

Hi All I am using Django rest framework as my backend ,I fetching some data from backed i’m getting get request very well but when i’m posting something via post method i’m getting POST http://localhost:8000/api/v1/customers 415 (Unsupported Media Type) error

Here is my code look Like

My model customer.js

import DS from 'ember-data';

export default DS.Model.extend({
  name: DS.attr(),
  company: DS.attr(),
  city: DS.attr(),
});

controller customers.js import Controller from ‘@ember/controller’;

export default Controller.extend({
  name: '',
  company: '',
  city: '',

  actions:{
    newCustomer(){
      const name = this.get('name');
      //console.log(this.get('name'));
      const company = this.get('company');
      const city = this.get('city');
      let newOne = this.store.createRecord('customer',{
        name:name,
        company:company,
        city:city,
      });
      newOne.save();
    }
  }
});

route customers.js

import Route from '@ember/routing/route';

export default Route.extend({
  model(){
    return this.store.findAll('customer');
  }
});

my hbs file customers.hbs

<table>
  <tr>
    <th>Name</th>
    <th>Company </th>
    <th>City</th>
  </tr>
  {{#each model as |customer|}}
  <tr>
    <td>{{customer.name}}</td>
    <td>{{customer.company}}</td>
    <td>{{customer.city}}</td>
  </tr>
  {{/each}}
</table>
NAME:{{input type="text" value=name}}<br>
Company:{{input type="text" value=company}}<br>
city:{{input type="text" value=city }}<br>
<button class="btn btn-primary" {{action 'newCustomer'}} >Request</button>

{{outlet}}