Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- POST /api/signin HTTP/1.1
- Host: myproj.herokuapp.com
- Cache-Control: no-cache
- Content-Type: application/x-www-form-urlencoded
- email=joe%40gmail.com&password=1234567
- Remote Address:10.10.10.250:80
- Request URL:http://myproj.herokuapp.com/api/signIn
- Request Method:POST
- Status Code:400 Bad Request
- Request Headersview source
- Accept:application/json, text/plain, */*
- Accept-Encoding:gzip, deflate
- Accept-Language:en-US,en;q=0.8
- Connection:keep-alive
- Content-Length:53
- Content-Type:application/x-www-form-urlencoded; charset=UTF-8
- Host:rapidit.herokuapp.com
- Origin:http://localhost
- Referer:http://localhost/rapid/v3/src/app/index/
- User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36
- Form Dataview parsed
- {"email":"joe@gmail.com","password":"1234567"}
- var LoginResource = $resource("http://myproj.herokuapp.com/api/signIn", {}, {
- post: {
- method: "POST",
- isArray: false,
- headers: {'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'}
- }
- });
- var loginUser = function (){
- return LoginResource.post(
- {
- email: "joe@gmail.com",
- password: "1234567"
- }
- ).$promise; //this promise will be fulfilled when the response is retrieved for this call
- };
- return loginUser;
- angular.module("AuthModule")
- .factory("authResource", ['$resource', 'appSettings', function ($resource, appSettings) {
- return {
- login: $resource(appSettings.serverPath + '/Token', null,
- {
- loginUser: {
- method: 'POST',
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
- transformRequest: function (data, headersGetter) {
- var str = [];
- for (var d in data)
- str.push(encodeURIComponent(d) + "=" + encodeURIComponent(data[d]));
- return str.join("&");
- }
- },
- })
- }
- }]);
- function transformUrlEncoded(data) {
- return $httpParamSerializer(parameters);
- }
- ...
- $resource('http://myproj.herokuapp.com/api/signIn', {}, {
- post: {
- method: "POST",
- headers: {'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'},
- transformRequest: transformUrlEncoded
- }
- });
- class AngularForm
- {
- constructor($scope, $http, $httpParamSerializerJQLike) {
- 'ngInject';
- this.http = $http;
- this.input= '';
- this.$httpParamSerializerJQLike = $httpParamSerializerJQLike;
- }
- sendForm(){
- let conf = {
- method: 'POST',
- headers: {'Content-Type': 'application/x-www-form-urlencoded'},
- url: '/api/input',
- data: this.$httpParamSerializerJQLike({'name_of_form': {'input':this.input}}),
- }
- this.http(conf).then( (response)=>{
- //success
- }, (response)=> {
- //error :(
- });
- }
- }
Add Comment
Please, Sign In to add comment