Hello
When trying to pass the FCC tests, I kept getting this error message:
(node:2677) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
So I checked all files in the boilerplate repl to see where ‘_headers’ was written (apparently ‘_headers’ cannot be used any more in Node.js, giving rise to this error)
I noticed ‘_headers’ was written in the file ‘fcctesting.js’ on line 75, as follows:
app.get('/_api/app-info', function(req, res) {
var hs = Object.keys(res._headers)
.filter(h => !h.match(/^access-control-\w+/));
var hObj = {};
hs.forEach(h => {hObj[h] = res._headers[h]});
delete res._headers['strict-transport-security'];
res.json({headers: hObj});
});
Node.js documentation says the following concerning this matter:
DEP0066: OutgoingMessage.prototype._headers, OutgoingMessage.prototype._headerNames#
History
Type: Runtime
The http module OutgoingMessage.prototype._headers and OutgoingMessage.prototype._headerNames properties are deprecated. Use one of the public methods (e.g. OutgoingMessage.prototype.getHeader(), OutgoingMessage.prototype.getHeaders(), OutgoingMessage.prototype.getHeaderNames(), OutgoingMessage.prototype.getRawHeaderNames(), OutgoingMessage.prototype.hasHeader(), OutgoingMessage.prototype.removeHeader(), OutgoingMessage.prototype.setHeader()) for working with outgoing headers.
The OutgoingMessage.prototype._headers and OutgoingMessage.prototype._headerNames properties were never documented as officially supported properties.
Changing ‘._headers’ to ’ .getHeaders()’ makes the ‘deprecated’ error disappear
Thanks for your time
Jaime
Your project link(s)
solution: https://replit.com/@jaimeggb/messageboard
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
Challenge: Anonymous Message Board
Link to the challenge: