The Movie Database Support

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}) } }

6 replies (on page 1 of 1)

Jump to last post

@DimpleChoudhary said:
why tmdb api key is not connecting with nodejs
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})
    }
}

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

Yes currently i am using tmdb_api_token just i named it like this for my ease. Nothing is working please help me out.

Did you receive an Error Message?
Copy and paste here the entire text of the message.

{ "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.

@DimpleChoudhary said:

{
    "success": false,  
    "message": "Client network socket disconnected before secure TLS connection was established"  
}

. . . This is what i am getting on vscode. Please help me.

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)

It looks like you're trying to connect via SSL3 (which is TLS 1.0) which has been deprecated for multiple years.
You need to make sure you are trying to connect with TLS 1.1 or higher.
TLS 1.1 is going to be deprecated soon, so you should really make sure you're using TLS 1.2 or 1.3.

https://www.themoviedb.org/talk/6559e1fe7f054018d24895fd?page=1#655b8728ea84c710910e9dd2

This user may have the same problem.
https://www.themoviedb.org/talk/661786d06b5fc2014a28183c

Can't find a movie or TV show? Login to create it.

Global

s focus the search bar
p open profile menu
esc close an open window
? open keyboard shortcut window

On media pages

b go back (or to parent when applicable)
e go to edit page

On TV season pages

(right arrow) go to next season
(left arrow) go to previous season

On TV episode pages

(right arrow) go to next episode
(left arrow) go to previous episode

On all image pages

a open add image window

On all edit pages

t open translation selector
ctrl+ s submit form

On discussion pages

n create new discussion
w toggle watching status
p toggle public/private
c toggle close/open
a open activity
r reply to discussion
l go to last reply
ctrl+ enter submit your message
(right arrow) next page
(left arrow) previous page

Settings

Want to rate or add this item to a list?

Login