swagger-api/swagger-codegen

JavaScript Module - LoginRequest doesn't seem to work

Open

#2,892 建立於 2016年5月17日

在 GitHub 查看
 (11 留言) (0 反應) (0 負責人)HTML (12,701 star) (5,474 fork)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?

貢獻者指南