TL;DR
I think you are looking for the function findPetsByStatus instead of findByStatus:
Swagger('http://petstore.swagger.io/v2/swagger.json').then((client) => {
client.apis.pet.findPetsByStatus({status: 'available'}).then((result) => {
console.log(result);
});
});
How I found the correct function name
I agree that it's kind of confusing because the swagger api does list a
GET request /pet​/findByStatus and the function name doesn't correspond with this.
I found the correct function name by logging the response from Swagger(...), called client in your example, and looking through the properties and values this object has:
Swagger('http://petstore.swagger.io/v2/swagger.json').then((client) => {
console.log(client)
});
Explanation about Promises relating to your question
In the documentation we can read that Calling Swagger(url, options) returns a Promise (https://www.npmjs.com/package/swagger-react-native-client#constructor-and-methods).
The Promise object represents the eventual completion (or failure) of an asynchronous operation, and its resulting value.
Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
So this means that in the then clause we have access to the resulting value of the (successful) asynchronous operation that is the Swagger(...) call. You've called this result client in your example.
This result is an object that holds a lot of different data, but importantly for your question; it has a property called apis which has an object as a value. This object contains all the api related functions you can use.
Representation of object returned from Swagger Promise
Here is a highly formatted and slightly adjusted (Adding quotes to [Object] and [Function anonymous] instances) representation of what you get when you log client in your example:
{
"apis": {
"pet": {
"addPet": "[Function anonymous]",
"deletePet": "[Function anonymous]",
"findPetsByStatus": "[Function anonymous]",
"findPetsByTags": "[Function anonymous]",
"getPetById": "[Function anonymous]",
"updatePet": "[Function anonymous]",
"updatePetWithForm": "[Function anonymous]",
"uploadFile": "[Function anonymous]"
},
"store": {
"deleteOrder": "[Function anonymous]",
"getInventory": "[Function anonymous]",
"getOrderById": "[Function anonymous]",
"placeOrder": "[Function anonymous]"
},
"user": {
"createUser": "[Function anonymous]",
"createUsersWithArrayInput": "[Function anonymous]",
"createUsersWithListInput": "[Function anonymous]",
"deleteUser": "[Function anonymous]",
"getUserByName": "[Function anonymous]",
"loginUser": "[Function anonymous]",
"logoutUser": "[Function anonymous]",
"updateUser": "[Function anonymous]"
}
},
"errors": [],
"originalSpec": "undefined",
"spec": {
"$$normalized": true,
"basePath": "/v2",
"definitions": {
"ApiResponse": "[Object]",
"Category": "[Object]",
"Order": "[Object]",
"Pet": "[Object]",
"Tag": "[Object]",
"User": "[Object]"
},
"externalDocs": {
"description": "Find out more about Swagger",
"url": "http://swagger.io"
},
"host": "petstore.swagger.io",
"info": {
"contact": "[Object]",
"description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
"license": "[Object]",
"termsOfService": "http://swagger.io/terms/",
"title": "Swagger Petstore",
"version": "1.0.5"
},
"paths": {
"/pet": "[Object]",
"/pet/findByStatus": "[Object]",
"/pet/findByTags": "[Object]",
"/pet/{petId}": "[Object]",
"/pet/{petId}/uploadImage": "[Object]",
"/store/inventory": "[Object]",
"/store/order": "[Object]",
"/store/order/{orderId}": "[Object]",
"/user": "[Object]",
"/user/createWithArray": "[Object]",
"/user/createWithList": "[Object]",
"/user/login": "[Object]",
"/user/logout": "[Object]",
"/user/{username}": "[Object]"
},
"schemes": [
"https",
"http"
],
"securityDefinitions": {
"api_key": "[Object]",
"petstore_auth": "[Object]"
},
"swagger": "2.0",
"tags": [
"[Object]",
"[Object]",
"[Object]"
]
},
"url": "http://petstore.swagger.io/v2/swagger.json"
}