0

First of all i have seen a lot of resources and tried them but with no luck.

I am trying to get some data from node server by posting two variables.

Note: I would prefer to not use JQuery if Possible

I think the problem is here:

var data = {
        "username": "trumpt",
        "offset": "0"
      };

here is a fiddle http://jsfiddle.net/pa21anen/

Edit: I am getting the output as {"errors":"Invalid Input"} but it should be this with the same url and data and request type. I have successfully implemented it in android, ios, windows 10 apps

{
  "notifications": [
    {
      "id": 1,
      "sender": "trumpt",
      "title": "test 1",
      "body": "Hello,\nFor all of those who use neo4j as a database along side with node.js, I have created a service that mediates any listing, finding or filtering request between an api and a neo4j database. The communication is done over rest api. \nThis service alows you to find/list any node from within your neo4j database using related nodes properties (from any relationship distance) \nIt was build as light as possible and it's only purpose is to generate appropriate cypher queries based on given filters and not intens processing\nIt is very easy to deploy and use.\nIssues, Pull requests and Enhancement requests are very welcomed and encouraged ! grin emoticonHello,\nFor all of those who use neo4j as a database along side with node.js, I have created a service that mediates any listing, finding or filtering request between an api and a neo4j database. The communication is done over rest api. \nThis service alows you to find/list any node from within your neo4j database using related nodes properties (from any relationship distance) \nIt was build as light as possible and it's only purpose is to generate appropriate cypher queries based on given filters and not intens processing\nIt is very easy to deploy and use.\nIssues, Pull requests and Enhancement requests are very welcomed and encouraged ! grin emoticonHello,\nFor all of those who use neo4j as a database along side with node.js, I have created a service that mediates any listing, finding or filtering request between an api and a neo4j database. The communication is done over rest api. \nThis service alows you to find/list any node from within your neo4j database using related nodes properties (from any relationship distance) \nIt was build as light as possible and it's only purpose is to generate appropriate cypher queries based on given filters and not intens processing\nIt is very easy to deploy and use.\nIssues, Pull requests and Enhancement requests are very welcomed and encouraged ! grin emoticon\nHello,\nFor all of those who use neo4j as a database along side with node.js, I have created a service that mediates any listing, finding or filtering request between an api and a neo4j database. The communication is done over rest api. \nThis service alows you to find/list any node from within your neo4j database using related nodes properties (from any relationship distance) \nIt was build as light as possible and it's only purpose is to generate appropriate cypher queries based on given filters and not intens processing\nIt is very easy to deploy and use.\nIssues, Pull requests and Enhancement requests are very welcomed and encouraged ! grin emoticon",
      "priority": 3,
      "time": 1455503708,
      "type": 1,
      "attachments": "image458286.jpg,pdf-sample.pdf,sample.doc,SampleGrades.xls"
    },
    {
      "id": 2,
      "sender": "trumpt",
      "title": "test 2",
      "body": "another test notif",
      "priority": 1,
      "time": 1455474927,
      "type": 1,
      "attachments": "oimage458286.jpg"
    },
    {
      "id": 3,
      "sender": "trumpt alter",
      "title": "test by new user",
      "body": "just a frickin' test",
      "priority": 2,
      "time": 1455478746,
      "type": 1,
      "attachments": null
    }
  ]
}
14
  • What exactly is the nature of the issue? "no luck" is not enough for us understanding the problem Commented Feb 25, 2016 at 19:34
  • check the fiddle please Commented Feb 25, 2016 at 19:34
  • I checked it, but I can't know from the fiddle if it's a server issue or not (You can add to server side code, it might help) Commented Feb 25, 2016 at 19:35
  • 1
    Inspect the actual request in browser dev tools network and see what is actually sent and returned and headers are as expected etc Commented Feb 25, 2016 at 20:02
  • 1
    here is working demo : jsfiddle.net/1hkamzvr/1 I'll need a bit more, to look into getting rid of "jquery" Commented Feb 25, 2016 at 20:07

1 Answer 1

1

This is the way, how you can serialize data without JQuery for POSTing to server in AngularJS.

.controller('myCtrl', function($scope, $http, $httpParamSerializerJQLike) {
    $scope.SendData = function() {

      var data = {
        "username": "trumpt",
        "offset": "0"
      };

      $http({
          method: 'POST',
          url: 'https://trumpt-nigharsh.c9users.io/notifications/getAll',
          data: $httpParamSerializerJQLike(data),
          headers: {'Content-Type': 'application/x-www-form-urlencoded'}

      }).success(function(data, status, headers, config) {
          $scope.PostDataResponse = data;
        })
        .error(function(data, status, header, config) {
          $scope.PostDataResponse = data
        });
    };

Working sample here: https://plnkr.co/edit/Wp3dj6FBIq09V3tbDPV0?p=preview

NB! this serialization was introduced only in some latter AngularJS builds. Tested on 1.4.8 Edit: Short version for POST: https://plnkr.co/edit/EGXIBJV24H0u7QO8JYEX?p=preview

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.