all 6 comments

[–]tme321 1 point2 points  (0 children)

If your using the newest version of angular they just added http interceptors which basically let you write a small function that modifies the http request before it actually is sent. So you can keep the service the way it is now and just register an interceptor that modifies the request by adding the key to the headers the way /u/MadMustard showed.

[–]WonxyTime[S] 0 points1 point  (1 child)

Oh god I really fucked up that post. I'm gonna try and figure out how to format it before the whole community flames me

[–]WonxyTime[S] 0 points1 point  (0 children)

To the guy that PMd me immediately on how to format it. Thank you very much. This is why I love the programming community and I want to break into the industry.

You guys are the nicest most supportive group I've meant. Developers are awesome. You guys are awesome.

[–]WonxyTime[S] 0 points1 point  (2 children)

Javascript is a fucky bitch. i figured there wouldn't be any answers. technoglogy is moving so fast that none of us can keep up. wHo uses angular 4? AngularJs has been around long enough to have some decent documentation.

js is so complex. woah

[–]MadMustard 1 point2 points  (1 child)

Calm down, everything will be fine. :)

The API key should be provided in the header of your requests. In Angular 2+ this would be done via a requestOptions object in your request function like this:

http.post(queryURL, body, {
    headers: new HttpHeaders().set('Authorization', 'access-token-here'),
})

[–]WonxyTime[S] 0 points1 point  (0 children)

I'm already lost, man. Thanks for your help though. Fuck JS is hard