swagger-api/swagger-codegen

JavaScript Module - LoginRequest doesn't seem to work

Open

#2,892 opened on 2016年5月17日

GitHub で見る
 (11 comments) (0 reactions) (0 assignees)HTML (12,701 stars) (5,474 forks)batch import
Client: JavaScript/Node.jsIssue: Bughelp wanted

説明

Greets,

I used swagger-codegen to generate a node module that I could then reference in my React project. This worked fine and I have it up and running, however the LoginRequest method doesn't appear to be working right. I just want to make sure I have the syntax correct. The following code always sends an empty body to the server, resulting in a 500 error. Is there something wrong with it?

(note: the auth info is obviously fake, but even with fake creds it should return a 401, not a 500 -- with the real creds, it's still a 500 because they're never being sent)


import SwaggerJsClient from 'swagger-js-client';

const api = new SwaggerJsClient.DefaultApi()

const opts = {
  'body': new SwaggerJsClient.LoginRequest({ email: 'test@test.com', password: 'testme' }),
};

const callback = (error, data, response) => {
  console.log('error: ', error);
  console.log('data: ', data);
  console.log('response: ', response);
};

api.login(opts, callback);

If I skip using the LoginRequest() method and just do the following, it works:

const opts = {
  'body': {
    'email': 'test@test.com',
    'password': 'testme',
  },
};

I've looked through the docs, I've tried using JSON.stringify() on the data I'm passing to LoginRequest(), and even tried to do some testing on LoginRequest.js but haven't been able to figure out what the problem is. Any ideas?

コントリビューターガイド