Skip to content

Uncaught Swoole\Error: API must be called in the coroutine in #101

@mkmnstr123

Description

@mkmnstr123

Hello,

So I've been trying to execute the order function, but I am getting this error:
PHP Fatal error: Uncaught Swoole\Error: API must be called in the coroutine in .../vendor/react/event-loop/src/StreamSelectLoop.php:290

It is weird because I can query the websocket and everything, but not when trying to run this code:

go(function () use ($priceUSDT, $amountUSDTAfterFee) {
                $auth = new Auth('**********', '****', "********", Auth::API_KEY_VERSION_V2);
                $api = new Order($auth, new SwooleHttp);

                go(function () use ($api, $priceUSDT, $amountUSDTAfterFee) {
                    try {
                        $result = $api->create([
                            'clientOid' => uniqid(),
                            'price' => $priceUSDT,
                            'size' => $amountUSDTAfterFee,
                            'symbol' => "{$this->workOnCurrency}-USDT",
                            'type' => 'market',
                            'side' => 'buy',
                        ]);
                        var_dump($result);
                    } catch (\Throwable $e) {
                        var_dump($e->getMessage());
                    }
                });
            });

I did installed the following, as mentioned in the docs:

composer require "kucoin/kucoin-php-sdk:~1.1.0"
pecl install swoole
composer require swlib/saber

Can you guys help pls

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions