mercredi 9 mai 2018

Post request in Emberjs with Django rest

I am trying to do some crud applications My Backend is Django Rest Framework front end i'm using Emberjs

I am not able to perform post request i'm getting unsupported media error here is my code

//model js customer.js

import DS from 'ember-data';

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


//route customer.js

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

export default Route.extend({
  model(params){
    return Ember.RSVP.hash({
      customers: this.store.findAll('customers'),
    })
  },
  actions:{
    saveCustomer(){
      let customer = this.store.CreateRecord('customers',{
        name: this.getProperties('name'),
        company: this.getProperties('company'),
        city: this.getProperties('cist'),
      })
      customer.save();
    }
  },
});


//template customers.hbs

<table>
  <tr>
    <th>Name</th>
    <th>Company</th>
    <th>City</th>
  </tr>
  
     <tr>
       <td></td>
       <td></td>
       <td></td>
     </tr>
   
</table>

  <div class="layout-row">
    <div class="layout-column flex-50">
      
      
      
    </div>
  </div>
  <div class="layout-row">
    Submit
  </div>



// adapter application.js

import DS from 'ember-data';

export default DS.RESTAdapter.extend({
  namespace: 'api/v1',
  host: 'http://localhost:8000'
});

any one who can help to get out of this ..I am using my backed django rest framework.I tried my backed code in post man it works well but when i'm using with ember i'm not able to post request form client side




Aucun commentaire:

Enregistrer un commentaire