#41 Added sendRequest method for sending API requests
Merged by lbrabec. Opened by manishakanyal.
fedora-qa/ manishakanyal/landingpage sendRequestUtility  into  master

Download 41.patch

This PR adds a new wrapper method sendRequest() for sending API calls/requests.
Under the hood, it's using fetch() so in case we decide to move to any other utility to send API requests like Axios, SuperAgent, etc, all we've to do is make amendments in the sendRequest() wrapper method instead of changing fetch from all files.

From now on, if we've to create a new API request, we'll have to go in the following way ->
- Create a file in /api/ if needed.
- Add the *Api() method which calls the sendRequest() method and return the same.
-Catch errors wherever we're using the *Api() method.

sendRequest() supports the following this as of now-

sendRequest = ({
  url,
  method = "GET",
  body,
  queryParams,
})

Where,
url: is the URL where we've to make the request.
method: defaults to "GET", it can be any HTTP method.
body: is the body of the HTTP request in case we've to send it.
queryParams: In case we've to send any URL query param. It should be an object with key-value pairs.

Fixes: #18

There is a package-lock.json, you probably used npm instead of yarn, please get rid of that file.

Otherwise, the code itself looks good.

Metadata Update from @lbrabec:
- Pull-request tagged with: review in progress

1 new commit added

  • deleted package-lock

rebased onto 4237b0dd810eb5497a86d8ae7e601d766d73d40d

Removed the package-lock and squashed the commit.

Metadata Update from @lbrabec:
- Pull-request untagged with: review in progress
- Pull-request tagged with: review done

rebased onto 082b0d3f87468191907bf005693caa52a52663d1

@lbrabec, I have rebased merge conflicts to the current master, can you please have a look.

rebased onto 700613b46e91b4d9e7ccb9fb80c0a4fe4fba066e

Pull-Request has been merged by lbrabec

Metadata