0

I have two different applications. App 1 runs in localhost 3000 and App 2 localhost 3020. Here, I am trying to merge these applications using Angular JS.

App 1 web address is https://localhost:3000/jump

app.factory('actionFactory', function ($http) {
return {
    climbRecords: function (){
        ////...some codes 
        return $http.post('https://localhost:3020/climb/climbRecords', data, {
            headers: { 'Content-Type': undefined}
        )
    }
}, 

getClimbRecords: function (){
    return $http.get('https://localhost:3020/getClimbRecords');
 }
}

App 2 web address is https://localhost:3020/climb

Can you help me on how to write the url for $http.post and $http.get? Does the url needs to be https as well? Does the url needs to be address of the website?

John Smith
  • 129
  • 2
  • 15
  • What error or response are you getting with this code? – nishant agrawal Feb 02 '17 at 15:30
  • @nishantagrawal, there are no errors and response. It seems that it is not being able to connect with the external localhost. – John Smith Feb 02 '17 at 15:34
  • 1
    You may not be geting any response due to CORS error. a different port or subdomain is considered as cross domain by browser. To get data you can try using JSONP method of angular – nishant agrawal Feb 02 '17 at 15:42
  • @nishantagrawal, I will research on that and give it a try. – John Smith Feb 02 '17 at 15:44
  • You can read more in [this answer](http://stackoverflow.com/questions/31612931/cors-issue-on-localhost-while-calling-rest-service-from-angularjs) – nishant agrawal Feb 02 '17 at 15:49
  • @nishantagrawal, It is getting the data however it cannot display in the website. The data are being generated as json type from other website. Do you know how to display this json type using Angular JS? – John Smith Feb 03 '17 at 15:02
  • Please share some more code of your html and controller. I cab help you then – nishant agrawal Feb 03 '17 at 15:53

0 Answers0