Skip to content

access connector property from request? #408

Answered by Sammyjo20
wivaku asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @wivaku

Yes you can achieve this, however you would implement it slightly differently. It's a little hacky, but you can use the boot method to customise the request while it is being sent

use Saloon\Helpers\URLHelper;


class UserRequest extends Request
{
    /**
     * The HTTP method of the request
     */
    protected Method $method = Method::GET;

    /**
     * The endpoint for the request
     */
    public function resolveEndpoint(): string
    {
        return '/:account/myendpoint';
    }

    public function boot(PendingRequest $pendingRequest): void
    {
        $connector = $pendingRequest->getConnector();
        $baseUrl = $connector->resolveBaseUrl();

        $endpoint

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@wivaku
Comment options

Answer selected by wivaku
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants