Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request error #9

Closed
pudelos opened this issue May 16, 2021 · 1 comment
Closed

Request error #9

pudelos opened this issue May 16, 2021 · 1 comment

Comments

@pudelos
Copy link

pudelos commented May 16, 2021

Hi!
I tried logging into the librus and found a few solutions. Yours works best, but I need to do it in node.js. I tried and it gets error status 400. Everything works in this project, but maybe you'll know what the error is.

while (r == null) {
        try {
            r = axios.post('https://api.librus.pl/OAuth/Token', {
                data: {
                    "username": login,
                    "password": password,
                    "librus_long_term_token": "1",
                    "grant_type": "password"
                },
                headers: headers,
                statusText: 'OK',
                status: 200
            })


        } catch (error) {
            console.log(error)
        }
    }

(node:5460) UnhandledPromiseRejectionWarning: Error: Request failed with status code 400
    at createError (C:\Users\milew\Desktop\librus\librus-api\node_modules\axios\lib\core\createError.js:16:15)
    at settle (C:\Users\milew\Desktop\librus\librus-api\node_modules\axios\lib\core\settle.js:17:12)
    at IncomingMessage.handleStreamEnd (C:\Users\milew\Desktop\librus\librus-api\node_modules\axios\lib\adapters\http.js:260:11)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (internal/streams/readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:5460) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:5460) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@pudelos
Copy link
Author

pudelos commented May 16, 2021

I have already solved my problem. The solution was to use querystring.stringify

@pudelos pudelos closed this as completed May 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant