Coder Social home page Coder Social logo

Comments (4)

brendanbond avatar brendanbond commented on April 28, 2024

A better option here is probably the requestOptions plugin, see a trivial example here: https://codesandbox.io/p/sandbox/http-request-plugin-example-forked-y3m9v2?file=%2Fsrc%2Findex.js%3A8%2C19

I think the problem you're running into here, though, is that, at the moment, the request plugins don't accept asynchronous functions and can't really handle promises, so your code is not going to run and may just break the javascript execution by just passing Promise objects where actual options and request objects are expected. Although I would be interested to support asynchronous request plugin methods, for now you'll have to load any data that is needed by the plugin before registering it.

I am going to rename this issue and send it up the chain.

from react.

ebner87 avatar ebner87 commented on April 28, 2024

Hi Brendan,

Thanks for the quick response.

Well, I didn't post all the different alternatives I tried to not get a very long post, but I also tried returning the options (or request/value) variable directly trying to keep synchronous nature of it and the issues was the same: when I have the requestOptions in place, the request is not triggered once I select Resource in Data Source Type.

So, not really only for async functions.

from react.

brendanbond avatar brendanbond commented on April 28, 2024

Cool, what would help here is if you could throw up a minimally reproducible example on a codesandbox or something similar so we can get to the bottom of it, I'm still not quite sure I'm following.

from react.

ebner87 avatar ebner87 commented on April 28, 2024

Hi Brendan,

Nevermind. I was creating the codesandbox to send you and realized that I was using options.header.append to add the header to the request, this way is raising the issue I was talking about (where requests are not fired/triggered).

Changing it to options.header['custom-header'] did the trick.

I saw somewhere else that the this property was an object (or was being handled as such) instead of an array. It didn't come to my head to check it or try as an array (maybe I need some rest).

Thanks for the help though.

from react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.