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

"POST body payload" issue #88

Comments

@jcdesignweb
Copy link

jcdesignweb commented Jan 22, 2020

Hi takashi ! I am using you aws api client for my project and I have an problem, maybe, I 'm doing something wrong. I am using an API made by me. This API has an POST endpoint. but when I trying to invoke to me API from your client, happens that is not pass the "body", this is my code:

static getUserList(idList) {
    const pathParams = {};
    const pathTemplate = '/common/users/list';
    const method = 'POST';
    const additionalParams = {
      headers: {}
    };
    const body = { //"users": ["bfq3vjthebt34r7fjt20", "bhq2o55hebt2hu1np3b0"]};
      //This is where you define the body of the request
      users: idList
    };

    return apigClient.invokeApi(pathParams, pathTemplate, method, additionalParams, body);
  }
@jcdesignweb
Copy link
Author

jcdesignweb commented Jan 22, 2020

well, apparently the issue happens on the file: simpleHttpClient.js, when the code entry in this conditional 'if':

if (config.retries !== undefined) {
      simpleHttpRequest.baseURL = url;

      var client = _axios["default"].create(simpleHttpRequest); // Allow user configurable delay, or built-in exponential delay


      var retryDelay = function retryDelay() {
        return 0;
      };

      if (config.retryDelay === 'exponential') {
        retryDelay = _axiosRetry["default"].exponentialDelay;
      } else if (typeof config.retryDelay === 'number') {
        retryDelay = function retryDelay() {
          return parseInt(config.retryDelay);
        };
      } else if (typeof config.retryDelay === 'function') {
        retryDelay = config.retryDelay;
      }

      (0, _axiosRetry["default"])(client, {
        retries: config.retries,
        retryCondition: config.retryCondition,
        retryDelay: retryDelay
      });
      return client.request({
        method: verb
      });
    }

to test this case, its necessary set 'retries' and 'retryCondition' in your config like this:

const apigClient = apigClientFactory.newClient({
  invokeUrl: 'http://localhost:8082', // REQUIRED
  region: 'us', // REQUIRED: The region where the API is deployed.
  accessKey: '', // REQUIRED
  secretKey: '', // REQUIRED
  systemClockOffset: 0, // OPTIONAL: An offset value in milliseconds to apply to signing time
  **retries**: 4, // OPTIONAL: Number of times to retry before failing. Uses axios-retry plugin.
  **retryCondition**: err => {
    // OPTIONAL: Callback to further control if request should be retried.
    return err.response && err.response.status === 500; // Uses axios-retry plugin.
  }
});

@kndt84
Copy link
Owner

kndt84 commented Jan 23, 2020

Thanks for identifying the cause. I'll add the default arguments for retries and retryCondition.

lsanders pushed a commit to adastradev/aws-api-gateway-client that referenced this issue May 10, 2020
lsanders pushed a commit to adastradev/aws-api-gateway-client that referenced this issue May 10, 2020
@kndt84 kndt84 closed this as completed in 8c3895b Jun 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment