The forum is read-only. New threads, replies and edits are disabled.
possible bug in wade.postObject()
krumza

Hi.

I try use some post requests for another server (no, problem in not in cors-ajax)

var obj ={

    username: "admin",

    password: "admin"

}



wade.postObject( 'url/login', obj, function(callback){console.log(callback)} );


Recepient server work on node and wait json request:but what is:

wade.postObject send object as a plain text - it is feature or bug?

And how i can set custom headers to request?

I think is bag becasue jQuery same request 

$.ajax({

        url  :'url/login',

        type    :'POST',

        dataType:'json',

        data    : JSON.stringify(obj),

        contentType:"application/json",

        success: function(data, xhr){

            console.log(data)

        },

        error:function(xhr, ajaxOptions, thrownError){

           console.log(xnr)

        }

 });

Content-Type:application/json

And my API return true object

Gio

Hi

Yes, wade.postObject(...) sends the object as a text string.

You can try using wade.ajax(...) to do the request more explicitly, jquery-style.

Unfortunately wade.ajax doesn't support setting a content-type header yet. I'm adding it to the list of new features for the next versions.

However there is a chance that if you send a json object without a content-type header, the browser might set the correct MIME type all by itself.