Quantcast
Channel: Hooktheory Forum - Latest topics
Viewing all articles
Browse latest Browse all 2966

[API] Unable to retrieve data - help!

$
0
0

@aplan wrote:

Hello there,

I'm working on an AngularJS web app that utilizes the Hooktheory API. I've been able to obtain an authentication token, and am able to make successful GET requests via the Postman app, but when I run my web app on live-server through Chrome, my HTTP requests for the chord probability data keep returning the following error:

XMLHttpRequest cannot load https://api.hooktheory.com/v1/trends/nodes. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access. The response had HTTP status code 404.

Here is my code for the HTTP request:

    this.getSongExamples = function() {
        var promise =
            $http(
                {
                    method: 'GET'
                    , url: "https://api.hooktheory.com/v1/trends/nodes"
                    , headers: {
                          'accept': 'application/json'
                          , 'authorization': 'Bearer [ authentication token ]'
                          , 'content-type': 'application/json'
                      }
                }
            ).then( function( response ) {
                if ( response.status === 200 ) {
                  console.log( response );
                  return response;
                }
                console.log( 'Error: ' + response.error );
            } );

        return promise;
} )

Any ideas?

Thanks,
Andrew

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 2966

Trending Articles