I'm trying to make an http request to a Dreamfactory backend.
return this.$http({
method: "GET",
url: "http://.../DMO_emails?filter=nom%20LIKE%20%27xxx%25%27%20OR%20nom%20LIKE%20%27%25%20xxx%25%27",
headers: {
"X-Dreamfactory_Application-Name": "appName"
});
After the first request, any request returns an error:
net::ERR_EMPTY_RESPONSE
Change this
return this.$http({
method: "GET",
url: http://.../DMO_emails?filter=nom%20LIKE%20%27xxx%25%27%20OR%20nom%20LIKE%20%27%25%20xxx%25%27,
headers: {
"X-Dreamfactory_Application-Name": "appName"
});
to this
return $http({
method: "GET",
url: "http://.../DMO_emails?filter=nom%20LIKE%20%27xxx%25%27%20OR%20nom%20LIKE%20%27%25%20xxx%25%27",
headers: {
"X-Dreamfactory_Application-Name": "appName"
}
});
Related
I can't able to read the response from the server in angularjs code. in $http methode , but in chrome inspect network option , i can sea the request and response.
My code is
$http({
method: 'POST',
url: url,
data: data,
responseType: 'arraybuffer',
}).then(function successCallback(res) {
console.log('---res', res);
}, function errorCallback(res) {
console.log('---err', res);
});
$http({
method: 'POST',
url: url,
data: data,
responseType: 'arraybuffer',
transformResponse: appendTransform($http.defaults.transformResponse, function(value) {
return doTransform(value);
})
});
above code worked for me
can someone fix it, when i using postman my restfull is good but not from my client side
var req = {
method: 'POST',
url: 'http://localhost:8098/getfiles',
headers: {
'Content-Type': 'multipart/form-data',
},
data: { 'selectedFiles': 'D:\\quadtech\\Intellegent\\AppSpringBoot\\input\\bismillah.txt' }
}
return $http(req).then(function(response){console.log(response); return response;}, function(){});
error in my console is
POST http://localhost:8098/getfiles 500 ()
this is request from postman
Send using formData instead of data:
var req = {
method: 'POST',
url: 'http://localhost:8098/getfiles',
headers: {
'Content-Type': 'multipart/form-data',
},
formData: {
'selectedFiles': fs.createReadStream('D:\\quadtech\\Intellegent\\AppSpringBoot\\input\\bismillah.txt') }
}
return $http(req).then(function(response){console.log(response); return response;}, function(){});
see the docs: https://github.com/request/request#forms
I have the following Angular 1.5 $http request:
this.$http({
method: 'POST',
url: "example.com",
data: {
"action" : "myAction"
},
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
transformRequest: function(obj) {...}
});
And I'm trying to rewrite it to Angular2, but I don't know how the "data" and "transformRequest" properties translate. So far I have:
let options = new RequestOptions({
method: RequestMethod.Post,
headers: myHeader
});
this.http.post(
'example.com',
options
);
How can I add the Angular2 equivalent of "data" and "transformRequest"?
I have below $http.post request
var credentials = {username: "alpha", password: "beta"}
$http({
method: 'POST',
url: baseUrl
params: credentials
paramSerializer: '$httpParamSerializerJQLike',
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
});
This works fine but all credentials appended in the URL which was not a good approach as it display sensitive data
BUT when I change this to
$http({
method: 'POST',
url: baseUrl,
data: credentials,
headers: {'Content-Type': 'multipart/form-data'}
});
this does not work?
what Is the issue?
if we do not send any headers than in browser I can see the default
Content-Type:application/json;charset=UTF-8
so why exactly server do not accept this application/json ?
Is that issue related to server or on the angular side?
$http({
method: 'POST',
url: baseUrl,
data: $httpParamSerializerJQLike(credentials),
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
});
I'm trying to send a put request by angularjs. My app receptor is running laravel.
When I trying send the request, I get the following error message:
TypeError: Cannot set property '_method' of undefined
at $http.transformRequest (http://localhost:8000/js/controller-university.js:91:28)
at transformData (http://localhost:8000/js/libs/angular/angular.js:7433:12)
at serverRequest (http://localhost:8000/js/libs/angular/angular.js:8071:23)
at wrappedCallback (http://localhost:8000/js/libs/angular/angular.js:11572:81)
at wrappedCallback (http://localhost:8000/js/libs/angular/angular.js:11572:81)
at http://localhost:8000/js/libs/angular/angular.js:11658:26
at Scope.$eval (http://localhost:8000/js/libs/angular/angular.js:12701:28)
at Scope.$digest (http://localhost:8000/js/libs/angular/angular.js:12513:31)
at Scope.$apply (http://localhost:8000/js/libs/angular/angular.js:12805:24)
at HTMLFormElement.<anonymous> (http://localhost:8000/js/libs/angular/angular.js:19139:23)
Here my code:
update : function(data) {
return $http({
method: 'POST',
url: '/api/university'+data.id,
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
data: $.param(data)
transformRequest: function(data){
data._method = 'PUT';
return data;
}
});
},
What is wrong?
Here the correct code:
update: function(data){
return $http({
method: 'PUT',
url: '/api/university/'+data.id,
data: $.param(data),
headers: { 'Content-Type' : 'application/x-www-form-urlencoded' }
});
},
var request = {
method: 'put',
url: '/admin/banners/'+$scope.editid,
data: fields,
headers: {
'Content-Type':'application/json'
}
};
It worked for me.