Code Monkey home page Code Monkey logo

Comments (11)

tchak avatar tchak commented on September 17, 2024 1

Like @ryanto said, in order for fetch (or najax for that matter) to use relative requests it needs access to fastboot service, so the only way right now is to use a service to make your requests. I think it might be possible to dereference request information from fastboot service as a global in an instance-initializer, but seems hakish...

I have an addon with a fetch service https://github.com/tchak/ember-fetch-adapter
It obviously needs more docs...

from ember-fetch.

rwjblue avatar rwjblue commented on September 17, 2024

Great question! There are things that could to do resolve, but I think the fundamental issue is that when running fastboot the app itself does not have awareness of where it is being served from. Therefore it can’t know current protocol (e.g. for //foo.com style URLs) or host (e.g. /path type URLs).

To fix this we would need an API from fastboot to be told where we are being served from. I personally can’t recall if that is already a “thing” we support (quick search didn’t lead to an answer).

@kratiahuja - Do you recall?

from ember-fetch.

ryanto avatar ryanto commented on September 17, 2024

Fastboot has an initializer that configures node-ajax with the request's host: https://github.com/ember-fastboot/ember-cli-fastboot/blob/master/fastboot/initializers/ajax.js

Not sure how to do this with node-fetch though.

from ember-fetch.

RobbieTheWagner avatar RobbieTheWagner commented on September 17, 2024

We could probably do the same thing here, right @ryanto?

from ember-fetch.

ryanto avatar ryanto commented on September 17, 2024

You would have to wrap fetch, build an absolute url, and then call the original fetch with the full url.

@dfreeman did something like this in addon docs: ember-learn/ember-cli-addon-docs#179

from ember-fetch.

tchak avatar tchak commented on September 17, 2024

And ember-data will do it for you too: https://github.com/emberjs/data/blob/master/addon/adapters/rest.js#L1081-L1103

from ember-fetch.

RobbieTheWagner avatar RobbieTheWagner commented on September 17, 2024

I know ember-data works, but I don't really do much that actually needs ember-data, and for anyone who doesn't need it, it would be nice to still have first class support. I will try out your fetch service addon @tchak. Thanks!

from ember-fetch.

tchak avatar tchak commented on September 17, 2024

@rwwagner90 oh I absolutely agree with you we need better support for this without ember-data.

@rwjblue or @kratiahuja do you think it would be reasonable to expose request information on the global FastBoot?

from ember-fetch.

Caltor avatar Caltor commented on September 17, 2024

@rwwagner90 totally agree. Our team has never got to grips with / seen the benefit of ember data.

from ember-fetch.

RobbieTheWagner avatar RobbieTheWagner commented on September 17, 2024

@tchak I tried your service and it threw an error. I opened an issue. tchak/ember-fetch-adapter#1

from ember-fetch.

xg-wang avatar xg-wang commented on September 17, 2024

Closed by #143

from ember-fetch.

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.