samedi 20 avril 2019

How to getting ajax promise by the head of response only?

To put it simply: I need to handle the response from rails API to make something, but I need the header of response only, without any of data.

But then is not getting the response when it contains the header only.

In details:

rails Controller action:

def index
  # some logic here ...
  head :created
end

ember component action:

let adapter = getOwner(this).lookup('adapter:application');
adapter.ajax(
  adapter.buildURL('/index'), 'POST', { some_param: 'some_content' }
).then(() => { 'do something here...' });

So in this implementation { 'do something here...' } is never used. But it works successfully if change the controller-action:

def index
  render json: [], status: :created
end

but I do not need to render some of json in response.

So, the question is:

how can run code 'do something here...' for controller-action:

def index
  head :created
end

Any help is appreciated.




Aucun commentaire:

Enregistrer un commentaire