Guest User

Untitled

a guest
Dec 19th, 2017
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. POST /api/signin HTTP/1.1
  2. Host: myproj.herokuapp.com
  3. Cache-Control: no-cache
  4. Content-Type: application/x-www-form-urlencoded
  5.  
  6. email=joe%40gmail.com&password=1234567
  7.  
  8. Remote Address:10.10.10.250:80
  9. Request URL:http://myproj.herokuapp.com/api/signIn
  10. Request Method:POST
  11. Status Code:400 Bad Request
  12. Request Headersview source
  13. Accept:application/json, text/plain, */*
  14. Accept-Encoding:gzip, deflate
  15. Accept-Language:en-US,en;q=0.8
  16. Connection:keep-alive
  17. Content-Length:53
  18. Content-Type:application/x-www-form-urlencoded; charset=UTF-8
  19. Host:rapidit.herokuapp.com
  20. Origin:http://localhost
  21. Referer:http://localhost/rapid/v3/src/app/index/
  22. User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36
  23. Form Dataview parsed
  24. {"email":"joe@gmail.com","password":"1234567"}
  25.  
  26. var LoginResource = $resource("http://myproj.herokuapp.com/api/signIn", {}, {
  27. post: {
  28. method: "POST",
  29. isArray: false,
  30. headers: {'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'}
  31. }
  32. });
  33. var loginUser = function (){
  34. return LoginResource.post(
  35. {
  36. email: "joe@gmail.com",
  37. password: "1234567"
  38. }
  39. ).$promise; //this promise will be fulfilled when the response is retrieved for this call
  40. };
  41. return loginUser;
  42.  
  43. angular.module("AuthModule")
  44. .factory("authResource", ['$resource', 'appSettings', function ($resource, appSettings) {
  45.  
  46. return {
  47. login: $resource(appSettings.serverPath + '/Token', null,
  48. {
  49. loginUser: {
  50. method: 'POST',
  51. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  52. transformRequest: function (data, headersGetter) {
  53. var str = [];
  54. for (var d in data)
  55. str.push(encodeURIComponent(d) + "=" + encodeURIComponent(data[d]));
  56. return str.join("&");
  57. }
  58. },
  59. })
  60. }
  61.  
  62. }]);
  63.  
  64. function transformUrlEncoded(data) {
  65. return $httpParamSerializer(parameters);
  66. }
  67.  
  68. ...
  69.  
  70. $resource('http://myproj.herokuapp.com/api/signIn', {}, {
  71. post: {
  72. method: "POST",
  73. headers: {'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'},
  74. transformRequest: transformUrlEncoded
  75. }
  76. });
  77.  
  78. class AngularForm
  79. {
  80. constructor($scope, $http, $httpParamSerializerJQLike) {
  81. 'ngInject';
  82. this.http = $http;
  83. this.input= '';
  84. this.$httpParamSerializerJQLike = $httpParamSerializerJQLike;
  85. }
  86.  
  87. sendForm(){
  88.  
  89. let conf = {
  90. method: 'POST',
  91. headers: {'Content-Type': 'application/x-www-form-urlencoded'},
  92. url: '/api/input',
  93. data: this.$httpParamSerializerJQLike({'name_of_form': {'input':this.input}}),
  94. }
  95.  
  96. this.http(conf).then( (response)=>{
  97. //success
  98. }, (response)=> {
  99. //error :(
  100. });
  101.  
  102. }
  103.  
  104. }
Add Comment
Please, Sign In to add comment