简体   繁体   中英

the request in postman works but in angular it doesn't

enter image description here

I send the bearer token returned by the login and it works

enter image description here the token arrives but the api response is

Authentication credentials were not provided.

Had the same issue, solved it by passing a plain object, to the headers property like so!

return this.http.post('/test/hello',
        formData,
        {
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${token}`
            },
        }
    );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM