Httpclient URL limit

Asked

Viewed 48 times

0

Could someone tell me if there is any limitation to the size of a URL in httpclient in Angular?

I’m trying to call an api from the url below, but the last 6 characters are cut.

http://localhost/api_cco/ifix/return1tag.php?token=eyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiI3YWQ2YjMwNy03NTQwLTQ5NzQtOWY1OS01NWY5MjUzMGNjMzYiLCJzdWIiOiIzODIxNDZhNy1hYTkwLTRmMjgtYjYwNC00ZWNkZDJlNDBiN2EiLCJzY29wZSI6WyJoaXN0b3JpYW5fcmVzdF9hcGkucmVhZCIsImhpc3Rvcmlhbl9yZXN0X2FwaS53cml0ZSJdLCJjbGllbnRfaWQiOiJoaXN0b3JpYW5fcHVibGljX3Jlc3RfYXBpIiwiY2lkIjoiaGlzdG9yaWFuX3B1YmxpY19yZXN0X2FwaSIsImF6cCI6Imhpc3Rvcmlhbl9wdWJsaWNfcmVzdF9hcGkiLCJncmFudF90eXBlIjoicGFzc3dvcmQiLCJ1c2VyX2lkIjoiMzgyMTQ2YTctYWE5MC00ZjI4LWI2MDQtNGVjZGQyZTQwYjdhIiwib3JpZ2luIjoidWFhIiwidXNlcl9uYW1lIjoiUkVTVFVzZXIiLCJlbWFpbCI6IlJFU1RVc2VyQHViZXJhYmEiLCJhdXRoX3RpbWUiOjE1NjcwMTM3NjUsInJldl9zaWciOiJmNGVmM2MwMSIsImlhdCI6MTU2NzAxMzc2NSwiZXhwIjoxNTY3MDU2OTY1LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAvdWFhL29hdXRoL3Rva2VuIiwiemlkIjoidWFhIiwiYXVkIjpbImhpc3Rvcmlhbl9wdWJsaWNfcmVzdF9hcGkiLCJoaXN0b3JpYW5fcmVzdF9hcGkiXX0.OgfDNWitQq5psYLuKFvVV_w5P4kA15IoAXtHvBKx7rtJL9TucWoKKlIxI32DiWzLqGG7g4UZyTV1hdF5KV1WNnDA_x0LcqxEoUOqZo4ndj9940oqOd1bi9Lr7ibm4Jsfau2gEOwZpaiNUkR6cAd3eBISe9LwTXJKYlI63gUMmnC-K_9ZOnuKeOyzhJZKz5IkyuzoKdIQ8kVbGzzAwQaMpAngDr8aIaTjxiPoHjZtGh4XTD3Y0zRv0pdFp-LR3gWzhShxlORIxOGiDzpUd1pAzQKhiZq8lBIjGgQF3e_qK6703EjhofUE5pU2T-Cs9Pbq628Y1kmIW4-V01kyrftAzA&tag=0153_DLD_LD_CCO.05LT07N.F_CV&datai=2019-8-1T00:00:00&dataf=2019-8-1T23:00:00

With the cut the dataF parameter ends up without the ":00:00" generating error in the query.

1 answer

0


How do you feel about using enviroment to center your url?

export const environment = {
  production: true,
  apiBase: 'http://localhost/api_cco/'
};

And I see that this is a queryString.. would be nice if you use mount your headers and stop before making any request.

getHeaders(token: string) {
   const headers = new HttpHeaders();
   this.headers.append('Content-Type', 'application/json');
   this.headers.append('token', token);
   return headers;
}

Return this.http.get( ${environment.apiBase}, { headers: this.getHeaders() });

If this is a token you need for all requests have you considered using an Interceptor? and do it there?

intercept
...
 return request.clone({
        setHeaders: {
          'token': xAccessToken
        }
 });

Browser other questions tagged

You are not signed in. Login or sign up in order to post.