A node.js server gives "This is a string". (writeHeader, write( string), end).
When performing a $http request, I see that the node.js server is responding and sending the information back.
In Angular I perform the following request:
angular.module('phoneList').
component('phoneList', {
templateUrl: 'phone-list/phone-list.template.html',
controller: function PhoneListController($http) {
var self = this;
$http.get('http://127.0.0.1:8081/echo').then(function(response) {
self.data = response.data;
}, function(err) {
self.error = err;
self.status = response.status;
self.statusText = response.statusText;
});
}
});
Response
{"data":null,"status":-1,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"url":"http://127.0.0.1:8081/echo","headers":{"Accept":"application/json, text/plain, /"}},"statusText":""}
I tried both just sending JSON from node.js or HTML-text. No difference.
"status": -1
normally means that your backend is not available. Could be an CORSallow-origin
problem. Any errors in the console? – Haith