Discussions

Ask a Question

Remove file list from FormData in Angular JS

var request = { method: 'POST', url: rootDir + abc/ffft', data: formdata, headers: { 'Content-Type': undefined }, success: (function (d) { }), error: (function (d) { }), complete: function (d) { formdata.forEach(function (val, key, fD) { console.log(key); formdata.delete(key); }); var files = formdata.getAll("file[]"); console.log("file" + files); files.delete("file[]"); } this service not working in file delete
ANSWERED

Transform server response to match schema.

Hi Jason, Is there a way to tell js-data to parse a resource response object differently ? Let's say your server respond the following json : ``` { "i": 123, "n": "Alfred" } ``` And you want your resource to be defined as follow : ``` DS.defineResource("person", { schema: { id: "string", name: "string" } }); ``` I know I can do it with a http request/response interceptor in AngularJS, but I would like to do it on the resource level. Any idea ?
ANSWERED

Handling form-data

Hello there! First of all, thank you for this awesome project. Really helpful to have a convenient model layer in the AngularJS world. I have a question regarding form-data. Is there any documentation how to handle form-data with JS Data? I'm switching from $resource which allowed me to attach a CSV file to the request via a simple 'transformRequest' like this: var data = $resource('/data/:id', {}, { post: { method: 'POST', transformRequest: function(data) { var fd = new FormData(); fd.append('file', data); return fd; }, headers: {'Content-Type': undefined} } }; I couldn't figure out how to do the same with JS Data.
ANSWERED

json request suffix

How can you set a .json suffix to all requests? Like in restangular: https://github.com/mgonto/restangular#setrequestsuffix
ANSWERED

Customizing HTTP Api

The API of our server is a bit different from your conventions, a typical query will look like this: www.myurl.com/contact.json?$filter=id eq 1 Is writing a completely new adapter the only way to accomplish this, or are there any hooks to customize standard DSHttpAdapter's url parsing? many thx, timm
ANSWERED

Nested endpoint with shared id

I am attempting to use an API that has the following endpoint layout. I'm not sure how to define the resources in js-data to match it. GET /api/buildings Returns an array of buildings GET /api/buildings/90 Returns an object containing a summary from the specified building GET /api/buildings/90/info Returns an object containing detailed information from the specified building PUT /api/building/90/info Update the information of a building The building endpoint and the info endpoint share the same ID. I have two resources defined: Building and BuildingInfo. My first thought was to define a belongsTo relationship in BuildingInfo with parent = true, however this results in js-data generating a url containing the ID twice (/api/building/90/info/90). I suspect js-data does not support this use case currently. I'm hoping to find out how I can do it with minimal changes to js-data.
ANSWERED

Data caching

Hi, Is it possible to combine the localStorage module with js-angular-data and use it as a cache provider? Thanks
ANSWERED

Create nested resources trough parent

Is there a way to create associated records through the parent? Like in rails (http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html)

Relations get not saved in object reference

Hi, jsdata acctually makes a put and the rest stores the correct object but the promise of update still returns the old object in javascript.
ANSWERED

Testing

How im able to implement JSData into test, have a wrapper function thats depending on DS.find to acctually get some objects. But as i execute it with an $httpBackend.expectGET('xxx').respond({'someobjectkey': 'someobjectvalue'}); JS data doesnt seem to execute anything on $http in this case.