I'm trying to send a JSON file to my Node.js app via Protocol.HTTP. The file is correctly sent, but I can't access to an array. Here is the relevant code :

Client side

    var vectorProtocol = new OpenLayers.Protocol.HTTP({
                    url: '/getcoords',
                    format: vectorFormat,
                    readWithPOST: true,
                    params: {
                        "code_company": "8501",
                        "data_company": [
                                "origin": "2013P00109",
                                "type": "LJ",
                                "naf": "5610A",
                                "origin": "2013P00110",
                                "type": "FJ",
                                "naf": "5481"

Server side, I try to build an array with only the "origin" field of my array "data_company":

function getCoords(params, callback) {
      var arrOrigin = params.data_company.map(function(d) {
         return d.origin;

And I get this error :

TypeError: Object [object Object] has no method "map"

It seems that my "data_company" array is not parsed. Is there a reason for that ? And a workaround ?


1 Answer 1


In server side convert json type to array.

  • Something to be aware of is that any answers (and questions) that are shorter than about a paragraph get flagged up for review because often answers of such length provide insufficient information about what the answer is based on (experience, link to a bulletin board, etc). If you are able to edit you answer to provide some more supporting information I suspect it will be far more likely to attract some upvotes too.
    – PolyGeo
    Aug 21, 2014 at 22:28

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.