dilame / instagram-private-api

NodeJS Instagram private API SDK. Written in TypeScript.
MIT License
5.99k stars 1.14k forks source link

TypeError: Cannot read property 'toString' of null #1379

Open virtueer opened 3 years ago

virtueer commented 3 years ago

https://github.com/dilame/instagram-private-api/blob/8e2a5aa83cbd93e268cfdcb5ca9148a29e787afb/src/core/request.ts#L199

When i save state, the euDCEnabled comes null and this code trying to "null.toString()". and app gives me TypeError

i changed the code to (typeof this.client.state.euDCEnabled === 'undefined' || this.client.state.euDCEnabled === null) ? void 0 : this.client.state.euDCEnabled.toString(),

its worked.

Nerixyz commented 3 years ago

You may also use this.client.state.euDCEnabled?.toString(). This does the same and is more compact.