contiamo / restful-react

A consistent, declarative way of interacting with RESTful backends, featuring code-generation from Swagger and OpenAPI specs 🔥
MIT License
1.87k stars 109 forks source link

Get Component fails to resolve path without RestfulProvider's base prop #159

Closed Manishalexin closed 5 years ago

Manishalexin commented 5 years ago

Describe the bug If Get Component is used without RestfulProvider top-level configuration, the path resolution adds a preceding slash to endpoints. This does not happen with the useGet method. It works as expected. For example, the below code will result in incorrect get request of /https://dog.ceo/api/breeds/image/random

const App = () => {
  <Get path="https://dog.ceo/api/breeds/image/random">
    {randomDogImage => (
      <img
        alt="Here's a good boye!"
        src={randomDogImage && randomDogImage.message}
      />
    )}
  </Get>;
};

To Reproduce Steps to reproduce the behavior:

  1. Create a new React/React-Native Project
  2. yarn add restful-react
  3. Add the Get Component in your App.tsx with a url to fetch data.
  4. Check the actual fetched URL in Network tab

    Reproducible Demo

Expected behavior Even without the global configuration of RestfulProvider, Get Component should parse the right URL and fetch the data.

Screenshots N/A

Desktop (please complete the following information):

Smartphone (please complete the following information): N/A

Additional context N/A