Tmdb api key is not connecting with node.js though i am using this code
export const getNowPlayingMovies = async (req, res)=>{
try {
const {data} = await axios.get('https://api.themoviedb.org/3/movie/now_playing', {
headers: {Authorization : Bearer ${process.env.TMDB_API_KEY}
}
})
console.log('TMDB_API_KEY:', process.env.TMDB_API_KEY);
const movies = data.results;
res.json({success: true, movies: movies})
} catch (error) {
console.error(error);
res.json({success: false, message: error.message})
}
}
找不到电影或节目?登录并创建它吧。
ticao2 🇧🇷 pt-BR 的回复
于 2025 年 08 月 01 日 9:19上午
Have you tried using your "TMDB_API_TOKEN" instead of "TMDB_API_KEY"?
Your API Read Access Token can be found here:
https://www.themoviedb.org/settings/api
Or here:
https://developer.themoviedb.org/reference/intro/getting-started
DimpleChoudhary 的回复
于 2025 年 08 月 02 日 1:11上午
Yes currently i am using tmdb_api_token just i named it like this for my ease. Nothing is working please help me out.
ticao2 🇧🇷 pt-BR 的回复
于 2025 年 08 月 02 日 12:02下午
Did you receive an Error Message?
Copy and paste here the entire text of the message.
DimpleChoudhary 的回复
于 2025 年 08 月 02 日 1:54下午
{ "success": false, "message": "Client network socket disconnected before secure TLS connection was established" }
This is what i am getting on postman.
[nodemon] starting node server.js Database connected Server listening at http://localhost:3000 AxiosError: Client network socket disconnected before secure TLS connection was established at AxiosError.from (/movie-ticket-booking-app/server/node_modules/axios/lib/core/AxiosError.js:92:14)
at RedirectableRequest.handleRequestError (/movie-ticket-booking-app/server/node_modules/axios/lib/adapters/http.js:620:25) at RedirectableRequest.emit (node:events:518:28) at eventHandlers. (\movie-ticket-booking-app\server\node_modules\follow-redirects\index.js:49:24) at ClientRequest.emit (node:events:518:28) at emitErrorEvent (node:_http_client:104:11) at TLSSocket.socketErrorListener (node:_http_client:518:5) at TLSSocket.emit (node:events:518:28) at emitErrorNT (node:internal/streams/destroy:170:8) at emitErrorCloseNT (node:internal/streams/destroy:129:3) at Axios.request (file:///E:/movie-ticket-booking-app/server/node_modules/axios/lib/core/Axios.js:45:41) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async getNowPlayingMovies (:/movie-ticket-booking-app/server/controllers/showController.js:7:24) { localAddress: undefined, port: 443, host: 'api.themoviedb.org', path: null, code: 'ECONNRESET', config: { transitional: { silentJSONParsing: true, forcedJSONParsing: true, clarifyTimeoutError: false }, adapter: [ 'xhr', 'http', 'fetch' ], transformRequest: [ [Function: transformRequest] ], transformResponse: [ [Function: transformResponse] ], timeout: 0, xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, maxBodyLength: -1, env: { FormData: [Function [FormData]], Blob: [class Blob] }, validateStatus: [Function: validateStatus], headers: Object [AxiosHeaders] { Accept: 'application/json, text/plain, /', 'Content-Type': undefined, Authorization: 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJ.............', 'User-Agent': 'axios/1.11.0', 'Accept-Encoding': 'gzip, compress, deflate, br' }, method: 'get', url: 'https://api.themoviedb.org/3/movie/now_playing', allowAbsoluteUrls: true, data: undefined }, request: Writable { _events: { close: undefined, error: [Function: handleRequestError], prefinish: undefined, finish: undefined, drain: undefined, response: [Function: handleResponse], socket: [Function: handleRequestSocket] }, _writableState: WritableState { highWaterMark: 16384, length: 0, corked: 0, onwrite: [Function: bound onwrite], writelen: 0, bufferedIndex: 0, pendingcb: 0, [Symbol(kState)]: 17580812, [Symbol(kBufferedValue)]: null }, _maxListeners: undefined, _options: { maxRedirects: 21, maxBodyLength: Infinity, protocol: 'https:', path: '/3/movie/now_playing', method: 'GET', headers: [Object: null prototype], agents: [Object], auth: undefined, family: undefined, beforeRedirect: [Function: dispatchBeforeRedirect], beforeRedirects: [Object], hostname: 'api.themoviedb.org', port: '', agent: undefined, nativeProtocols: [Object], pathname: '/3/movie/now_playing' }, _ended: true, _ending: true, _redirectCount: 0, _redirects: [], _requestBodyLength: 0, _requestBodyBuffers: [], _eventsCount: 3, _onNativeResponse: [Function (anonymous)], _currentRequest: ClientRequest { _events: [Object: null prototype], _eventsCount: 7, _maxListeners: undefined, outputData: [], outputSize: 0, writable: true, destroyed: false, _last: true, chunkedEncoding: false, shouldKeepAlive: true, maxRequestsOnConnectionReached: false, _defaultKeepAlive: true, useChunkedEncodingByDefault: false, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, strictContentLength: false, _contentLength: 0, _hasBody: true, _trailer: '', finished: true, _headerSent: true, _closed: false, _header: 'GET /3/movie/now_playing HTTP/1.1\r\n' + 'Accept: application/json, text/plain, /\r\n' + 'Authorization: Bearer eyJhbGciOiJIUzI1Ni...........\r\n' + 'User-Agent: axios/1.11.0\r\n' + 'Accept-Encoding: gzip, compress, deflate, br\r\n' + 'Host: api.themoviedb.org\r\n' + 'Connection: keep-alive\r\n' + '\r\n', _keepAliveTimeout: 0, _onPendingData: [Function: nop], agent: [Agent], socketPath: undefined, method: 'GET', maxHeaderSize: undefined, insecureHTTPParser: undefined, joinDuplicateHeaders: undefined, path: '/3/movie/now_playing', _ended: false, res: null, aborted: false, timeoutCb: [Function: emitRequestTimeout], upgradeOrConnect: false, parser: null, maxHeadersCount: null, reusedSocket: false, host: 'api.themoviedb.org', protocol: 'https:', _redirectable: [Circular *1], [Symbol(shapeMode)]: false, [Symbol(kCapture)]: false, [Symbol(kBytesWritten)]: 0, [Symbol(kNeedDrain)]: false, [Symbol(corked)]: 0, [Symbol(kChunkedBuffer)]: [], [Symbol(kChunkedLength)]: 0, [Symbol(kSocket)]: [TLSSocket], [Symbol(kOutHeaders)]: [Object: null prototype], [Symbol(errored)]: null, [Symbol(kHighWaterMark)]: 16384, [Symbol(kRejectNonStandardBodyWrites)]: false, [Symbol(kUniqueHeaders)]: null }, _currentUrl: 'https://api.themoviedb.org/3/movie/now_playing', [Symbol(shapeMode)]: true, [Symbol(kCapture)]: false }, cause: Error: Client network socket disconnected before secure TLS connection was established at TLSSocket.onConnectEnd (node:_tls_wrap:1732:19) at TLSSocket.emit (node:events:530:35) at endReadableNT (node:internal/streams/readable:1698:12) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { code: 'ECONNRESET', path: null, host: 'api.themoviedb.org', port: 443, localAddress: undefined } }
This is what i am getting on vscode. Please help me.
ticao2 🇧🇷 pt-BR 的回复
于 2025 年 08 月 05 日 12:16下午
This error message isn't from our server.
It's from a tool you're using.
Perhaps the conversations below can help you.
Axios Issues
https://www.themoviedb.org/talk/63e3d510db154f00812e67c6
https://www.themoviedb.org/talk/6037bbc2afa1b00043a76e2c
https://www.themoviedb.org/talk/5f621eae93388b003864513c
https://www.themoviedb.org/talk/5f55e3dd713ed40037f090d4
https://www.themoviedb.org/talk/5d5901d21749730017dd837a
https://www.themoviedb.org/talk/5bab86480e0a2664d4022f98
SSL / TLS ERROR
2023-10-19 https://www.themoviedb.org/talk/6531b98e9ac535087755c46a
2021-05-11 https://www.themoviedb.org/talk/609b316c8dbc33005858d98e
2020-12-07 https://www.themoviedb.org/talk/5fce79b8c0348b0040124570
2020-10-02 https://www.themoviedb.org/talk/5f769ee4021cee00372ae511
2020-06-21 https://www.themoviedb.org/talk/5eef5fc22e2b2c00376cc835
2020-04-16 https://www.themoviedb.org/talk/5e987f2fb339030015a2743c
2019-12-17 https://www.themoviedb.org/talk/5df8e40d26dac10012566e2c
https://www.themoviedb.org/talk/search?advanced_search=&query=SSL&with_category=&with_status%5B%5D=closed&with_status%5B%5D=open
Additionally, see what admin Travis Bell informed a user. (2023-11-20)
https://www.themoviedb.org/talk/6559e1fe7f054018d24895fd?page=1#655b8728ea84c710910e9dd2
ticao2 🇧🇷 pt-BR 的回复
于 2025 年 08 月 05 日 12:27下午
This user may have the same problem.
https://www.themoviedb.org/talk/661786d06b5fc2014a28183c