I've been working on this for a while and have done a lot of research too and can't seem to find a way to do something that seems rather simple. I have an ember application which needs to call an API on a different domain. Naturally this results in a cross domain issue and as a result I have setup a proxy using Sinatra on my local machine. This proxy is independent of my application. My application is running at localhost:4200 and my proxy is running at localhost:4567. When I send my post request from my application to my proxy, it gets to the api without any issue and control returns to my proxy. The response is stored in a variable aptly named "response". The following code is the portion which actually makes the request.
response = RestClient.post("#{TARGET_URL}?#{@query_string}",
@request_payload,
{
'client-key': @client_key,
'Content-Type': 'application/json; charset=UTF-8',
'Accept': 'application/json'
})
So, this Sinatra proxy is on localhost:4567. How would I send this response object back to my application which is waiting for a response to the post request sent to my proxy? For reference, I am using the rest-client library for this. Any help would be much appreciated. I'm sure there's a simple solution for this. Unfortunately, I just don't know what it is.
Aucun commentaire:
Enregistrer un commentaire