Aurelia fetch-client为发布请求抛出401

Aurelia fetch-client throws 401 for post requests

I'm facing an issue while trying to make httpPost request. It always returns 401 Unauthorized error.

We are using token based authentication from our server(Apache Tomcat7) with SpringSecurity plugin for generating authToken.

Below is how I configured HttpClient.

In constructor, I made httpClient configuration.

@inject(HttpClient)
export default class UtilService {

    constructor(http) {

        // Configure the HttpClient globally ( in entire app)
        http.configure(_http => {
            _http
                .useStandardConfiguration()
                .withBaseUrl(config.baseUrl)
                .withDefaults({
                    credentials: "same-origin",
                    headers: {
                        "Content-Type": "application/x-www-form-urlencoded",
                        "X-Requested-With": "Fetch",
                        "Accept": "*/*",
                        "Authorization": "Bearer "+localStorage[config.tokenName]
                    }
                })

                .withInterceptor({
                    responseError(error) {
                        if (error.status && error.status === 401) {
                            console.log("error recorded:"+error)
                        }
                        throw error;
                    }
                });
        });
        this.http = http;
    }
}

And calling function:

profileInfo(url, paramsObj) {

   // url = http://localhost:8082/xyz/api/v1/profileInfo
   // paramsObj = {access_token : localStorage[config.tokenName]};

   return this.http.fetch(url, {
       method: "POST",
       body: $.param(paramsObj)
    }).catch(err=>{
        console.log("failure:"+err);
        throw err
    }); 
}

I always get 401 (Unauthorized). Any help would be appreciated.