I have tried everything on this thread with no luck. Node.js https pem error: routines:PEM_read_bio:no start line
I am trying to do a very simple request to the google API to ask for a channel's information.
Things I have:
I can make a request to the yahoo weather API no problem using the same method.
var request = require('request');
request("https://www.googleapis.com/youtube/v3/channels?",{
part: "snippet,contentDetails,statistics",
id: "UCd534c_ehOvrLVL2v7Nl61w",
key: process.env.YOUTUBE_API_KEY
}, function(err, response, body){
if (err){
console.log(err);
}
console.log(body);
});
Here is the full error
Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
at Error (native)
at Object.createSecureContext (_tls_common.js:85:17)
at Object.exports.connect (_tls_wrap.js:1033:48)
at Agent.createConnection (https.js:82:22)
at Agent.createSocket (_http_agent.js:195:26)
at Agent.addRequest (_http_agent.js:157:10)
at new ClientRequest (_http_client.js:160:16)
at Object.exports.request (http.js:31:10)
at Object.exports.request (https.js:202:15)
at Request.start
(/home/ubuntu/workspace/node_modules/request/request.js:748:32)
undefined
Thanks for the help!
Give this a try instead. The query string parameters are not sent correctly, so the API responds that it could not find your key.
var request = require('request');
request({url: "https://www.googleapis.com/youtube/v3/channels?",
qs:{ part: "snippet,contentDetails,statistics",
id: "UCd534c_ehOvrLVL2v7Nl61w",
key: process.env.YOUTUBE_API_KEY
}
}, function(err, response, body){
if (err){
console.log(err);
}
console.log(body);
});