webofthings / webofthings.js

A gateway and server reference implementation of the Web of Things model
http://book.webofthings.io
Apache License 2.0
74 stars 26 forks source link

Why I can't see access the headers when requesting 'http://gateway.webofthings.io/' #10

Closed yassinej closed 6 years ago

yassinej commented 6 years ago

Hi, I'm trying to build a basic app that allows display data shared by the WoT Book Pi device. First I need to discover the properties and actions. I ant to check that the provided URL is a 'Thing'. I decided to check the content of the header Link. I use the following code with url = 'http://gateway.webofthings.io/'

return axios .get(url, { headers: { Accept: 'application/json' } }) .catch(err => { console.log('Error Discovering...', err); }) .then(res => { // Check model for links console.log(res.headers); });

I see the Headers in Postman or chrome Network tab. but Not in the res.headers. Can you help me with this problem? I think it is related to some "access-control-allow-headers" options..

domguinard commented 6 years ago

Hi Yassinej,

Better super later than never (very sorry about that, we missed a few issues!). I checked again and it does work on the server as you suggest. Are you trying to build a client app? Client side Javascript does not usually have access to the headers, see: https://stackoverflow.com/questions/220231/accessing-the-web-pages-http-headers-in-javascript Closing for now but please do reopen if you find any issue.