5655

Get data from ajax request to Angular

Question:

I have 2 requests

$.ajax({ type: "POST", url: "http://sandbox.gasvisor.com:9988/uaa/oauth/token", data: "grant_type=client_credentials", headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization':'Basic SVRXRV9XRUJfQVBQOml0d2VfY2xpZW50' }, success:function(data){ console.log(data); getData(data.access_token); } }) function getData(acess_token){ $.ajax({ type: "GET", url: "http://sandbox.gasvisor.com/api/v2/gobjects/search/withinRadius?longitude=24.711117&latitude=48.922633&radius=10", headers: { 'Authorization':'bearer'+acess_token }, success:function(data){ console.log(data); } }) }

They return json from server. I need to get data from Json file to my Angular listing. Pls help me.

Answer1:

Here is a simple example for one of your call:

$http({ method: 'POST', url: 'http://sandbox.gasvisor.com:9988/uaa/oauth/token', data: 'grant_type=client_credentials', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization':'Basic SVRXRV9XRUJfQVBQOml0d2VfY2xpZW50' }, }).then(function successCallback(response) { // this callback will be called asynchronously // when the response is available $scope.response = response; }, function errorCallback(err) { // called asynchronously if an error occurs // or server returns response with an error status. $scope.error = err; });

Recommend

  • How can a console application sudo itself under OS X if it needs root privileges? [closed]
  • PHP exec response as string?
  • React Router and Arbitrary Query Params: Page Refreshes Unintentionally on Load?
  • Uber API - requests endpoint cannot read read json
  • remove unicode characters but keep all special and English characters with preg_replace
  • Why isn't my “Fizz Buzz” test in R working?
  • Python PIL to extract number from image
  • Add reference to ASP.NET 5 Class Library from Framework 4.5 Class Library Project
  • CodeIgniter URI Parameter is partially bypassing an “if” statement
  • opencv display image without x server
  • IE11 throwing “SCRIPT1014: invalid character” where all other browsers work
  • nonblocking BIO_do_connect blocked when there is no internet connected
  • Do I need to reset a Perl hash index?
  • Display images in Django
  • How to render a blob on a canvas element?
  • iOS: Detect app start via notification press
  • Get data from AJAX - How to
  • Seeking advice on Jetty HttpClient Hang
  • does jqgrid support a multiple checkbox list for editing
  • Why is an OPTIONS request sent to the server?
  • Spring Data JPA custom method causing PropertyReferenceException
  • Spring security and special characters
  • Optimizing database types to compact database (SQLite)
  • C# - Serializing and deserializing static member
  • Bug in WPF DataGrid
  • How to recover from a Spring Social ExpiredAuthorizationException
  • Cross-Platform Protobuf Serialization
  • Sending data from AppleScript to FileMaker records
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • Do I've to free mysql result after storing it?
  • Circular dependency while pushing http interceptor
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • How to include full .NET prerequisite for Wix Burn installer
  • Revoking OAuth Access Token Results in 404 Not Found
  • AngularJs get employee from factory
  • How to set the response of a form post action to a iframe source?
  • Change div Background jquery
  • File not found error Google Drive API
  • Turn off referential integrity in Derby? is it possible?
  • Is it possible to post an object from jquery to bottle.py?