While attempting to utilize angular js $http for sending a post request to elasticSearch, I encounter an "Unexpected token : " Error.
Here is a snippet of my code:
var request= $http({
method: "post",
url: path,
accept:"*/*",
headers:{"Content-Type" : "application/x-www-form-urlencoded; charset: UTF-8"},
data:{
"query":{
"fuzzy":{
"title":{
"value": $scope.searchTerm,
"fuzziness":"1"
}
}
},
"highlight":{
"fields":{
"*":{}
}
}
}
});
Upon inspecting the form data section in the chrome console, I notice that the json has a trailing colon.
[{"query":{"fuzzy":{"title":{"value": $scope.searchTerm,"fuzziness":"1"}}},
"highlight":{"fields":{"*":{}}}}]: <--- this is the issue
This seems odd. Any suggestions on how to remove the trailing colon?