I am using Angular to save form input to $scope.tag. I can't make a client side external API call with the form information as a parameter, so I need to pass it to the server to do. How can i achieve this?
The steps:
- user submits form
- client makes request to server
- server makes request to external API
- server sends response back to client
How can I achieve this?
$scope.tag = '';
// client side
$http.get('/api')
.then(function(response) {
console.log(response);
});
// server side
app.get('/api', function (req, res) {
request('http://externalAPI.com/' + $scope.tag, function (req, res) {
res.json(data);
});
});