npm.io
1.0.2 • Published 4 years ago

flexf

Licence
MIT
Version
1.0.2
Deps
3
Size
7 kB
Vulns
23
Weekly
0

FlexF

Axios flex fetch

Proof Of Concept: Project/Library in initial state.

Response Lookup

Axios response reference

  "data": {},
  "status": null
  "statusText": null,
  "headers": {},
  "config": {},
  "request": {}
const axios = require("axios").default;
const { flexF, responseLookup } = require("flexf");

const response = responseLookup(
  flexF(axios)({
    /* config */
  })
);
const result = response("data"); // response reference

Shorthand methods for Axios HTTP requests

Axios also provides a set of shorthand methods for performing different types of requests. The methods are as follows:

  • request
  • get
  • delete
  • head
  • options
  • post
  • put
  • patch

Request Config: requestConfig

Follow The Request Config documentation provided by axios.


Request example

const axios = require("axios").default;
const { flexF, responseLookup } = require("flexf");

const r = responseLookup(
  await flexF(axios)({
    method: "get",
    url: "https://jsonplaceholder.typicode.com/todos/",
    requestConfig: {
      params: {
        id: 1,
      },
      responseType: "json",
    },
  })
);

const result = r("data");

Contributing

  • Fork it!
  • Create your feature branch: git checkout -b my-new-feature
  • Commit your changes: git commit -am 'Add some feature'
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request

Credits

Troubleshootings

This is just a personal project created for study / demonstration purpose and to simplify my working life, it may or may not be a good fit for your project(s).


Show your support

Please this repository if you like it or this project helped you!
Feel free to open issues or submit pull-requests to help me improving my work.


Author

Chris Michael

You can follow me on github · twitter


Copyright 2021 flexF.

Keywords