how can i fix this typescript error TS2339?


i try to implement discord oauth2 login into a website. I tried many tutorials, but no one really works. I found another YouTube Tutorial: https://youtu.be/RP0P_zGdvj8
and i think this should work. But i have a problem and i tried to fix it, but i failed… Here´s my code: I just pasted it in the JS section.
https://jsfiddle.net/Atrapfare/r3L2xz9h/1/
Some infos: Language TypeScript
The error in the console:

C:UsersDominikAppDataRoamingnpmnode_modulests-nodesrcindex.ts:692
    return new TSError(diagnosticText, diagnosticCodes);
           ^
TSError: ⨯ Unable to compile TypeScript:
src/index.ts:30:21 - error TS2339: Property 'access_token' does not exist on type 'String'.

30             const { access_token, refresh_token } = response.data;
                       ~~~~~~~~~~~~
src/index.ts:30:35 - error TS2339: Property 'refresh_token' does not exist on type 'String'.

30             const { access_token, refresh_token } = response.data;
                                     ~~~~~~~~~~~~~

    at createTSError (C:UsersDominikAppDataRoamingnpmnode_modulests-nodesrcindex.ts:692:12)
    at reportTSError (C:UsersDominikAppDataRoamingnpmnode_modulests-nodesrcindex.ts:696:19)
    at getOutput (C:UsersDominikAppDataRoamingnpmnode_modulests-nodesrcindex.ts:883:36)
    at Object.compile (C:UsersDominikAppDataRoamingnpmnode_modulests-nodesrcindex.ts:1185:30)
    at Module.m._compile (C:UsersDominikAppDataRoamingnpmnode_modulests-nodesrcindex.ts:1309:30)
    at Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Object.require.extensions.<computed> [as .ts] (C:UsersDominikAppDataRoamingnpmnode_modulests-nodesrcindex.ts:1313:12)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) {
  diagnosticText: "x1B[96msrc/index.tsx1B[0m:x1B[93m30x1B[0m:x1B[93m21x1B[0m - x1B[91merrorx1B[0mx1B[90m TS2339: x1B[0mProperty 'access_token' does not exist on type 'String'.rn" +
    'rn' +
    'x1B[7m30x1B[0m             const { access_token, refresh_token } = response.data;rn' +
    'x1B[7m  x1B[0m x1B[91m                    ~~~~~~~~~~~~x1B[0mrn' +
    "x1B[96msrc/index.tsx1B[0m:x1B[93m30x1B[0m:x1B[93m35x1B[0m - x1B[91merrorx1B[0mx1B[90m TS2339: x1B[0mProperty 'refresh_token' does not exist on type 'String'.rn" +
    'rn' +
    'x1B[7m30x1B[0m             const { access_token, refresh_token } = response.data;rn' +
    'x1B[7m  x1B[0m x1B[91m                                  ~~~~~~~~~~~~~x1B[0mrn',
  diagnosticCodes: [ 2339, 2339 ]
}

So it have to do anything with const {access_token, refresh_token} = response.data; but I have no idea how to fix it, I either don´t know what the meaning of this error in details :), so please help…

Source: JavaSript – Stack Overflow

October 1, 2021
Category : News
Tags: discord.js | javascript | node.js | oauth-2.0 | typescript

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.