question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose merged config in request

See original GitHub issue

The change from version 0.5 removed the ability to inject url parameters into the request for the model.

It is still possible to recover some of this by setting in the model:

static apiConfig = {
    url: '/foo/',
};

and only use api().request({}). I would like to recover all of the functionality by exposing the built config in the Request object returned by api(). This will let me modify the url property to inject parameters before calling request({}).

The alternative is to restore the original functionality by accepting an object in place of the url for the Request functions that will check if url has been set in the config and replace its keys in the url path with its values.

Update: I just noticed I can monkeypatch the Request object with my own functions and that the config isn’t available until the method call: https://github.com/vuex-orm/plugin-axios/blob/5c6f51135a58c4caa8b40234f8dd303c75626da2/src/api/Request.ts#L117-L123

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
cuebitcommented, May 13, 2020

@JKrol sure, you can define common options at model level as documented.

However, simply invoking User.api().get() without a URL is not possible. It’s not how axios functions.

If you want pre-configured or shorthand methods to simply invoke anywhere in your application, consider using Custom Actions which are designed to accommodate your exact requirements.

0reactions
JKrolcommented, May 13, 2020

I have similar question. Currently, each time I want to call API, I have to provide the URL. It would be great to have an option, to define the URL on the model level.

Example - lets say I have a User model. Now I want to call get on the user - I have to write:

User.api().get('/api/users');

If I have many places in code where I want to get users, I have to provide ‘/api/users’ URL in each place. It would be great to have a possibility to define URL in User model and then just call:

User.api().get();

Is this possible?

Read more comments on GitHub >

github_iconTop Results From Across the Web

WIP: Expose secrets configured for a job to Runner - GitLab
, This merge request adds or changes files that require a review from the Database team. ;, CHANGELOG missing: If you want to...
Read more >
Implements #156 expose config options (!95) · Merge requests ...
An error occurred while retrieving approval data for this merge request. Implements #156 expose config options. Code. Review changes. Check out branch ...
Read more >
libaccountsservice: Expose interfaces directory in pkg-config file (!16 ...
Just like the D-Bus interfaces directory is exposed in dbus-1.pc for the use of ... Merged Philip Withnall requested to merge pwithnall/accountsservice:pc- ...
Read more >
Expose and rename stream timeout config. (!231) · Merge requests ...
An error occurred while fetching the assigned milestone of the selected merge_request. Expose and rename stream timeout config.
Read more >
GitLab: Exposing value generated from CI to UI - Stack Overflow
Based on Arty-chan's comment I updated my CI config to perform a POST request to GitLabs API. Sample config: image: python run-test: script: ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found