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

createEffect doesn't resolve void Params #404

Closed
Guck111 opened this issue Oct 18, 2020 · 2 comments
Closed

createEffect doesn't resolve void Params #404

Guck111 opened this issue Oct 18, 2020 · 2 comments
Labels
bug Something isn't working typings Typescript public type definitions issues

Comments

@Guck111
Copy link

Guck111 commented Oct 18, 2020

I have this code:

export const getProviders = createEffect("getProviders", {
  handler() {
    return fetch(`http://localhost:8000/api/v1/constructor/providers/`)
  },
})

getProviders()

and I got: Expected 1 arguments, but got 0.

version: 21.5.0

@Guck111 Guck111 added bug Something isn't working needs triage labels Oct 18, 2020
@zerobias
Copy link
Member

This is not the most actual way of creating effect, it really does not support that yet, this is a bug. The bug was overlooked because variants with a function or with configuration are used much more often, and they indeed support handling void params:

import { createEffect } from 'effector'

export const getProviders = createEffect(() => {
  return fetch(`http://localhost:8000/api/v1/constructor/providers/`)
})

export const getProvidersWithConfig = createEffect({
    handler() {
      return fetch(`http://localhost:8000/api/v1/constructor/providers/`)
    },
    name: 'getProvidersWithConfig'
})

getProviders()
getProvidersWithConfig()

Try it in typescript repl

So I suggest using one of them

Anyway, we'll try to fix this variant as well

@zerobias zerobias added typings Typescript public type definitions issues and removed needs triage labels Oct 18, 2020
@zerobias
Copy link
Member

Fixed in effector 21.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working typings Typescript public type definitions issues
Projects
None yet
Development

No branches or pull requests

2 participants