Code Monkey home page Code Monkey logo

bs-axios's People

Contributors

cknitt avatar dependabot-preview[bot] avatar dependabot[bot] avatar flyjwayur avatar khady avatar marukami avatar meafmira avatar phillipj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bs-axios's Issues

socketPath config parameter

I was wondering if it was possible to include the socketPath parameter in makeConfig?
It is needed for example for communication with the local docker api.

Change name of labeled arg `method`

It looks like method is a reserved keyword in ocaml.

image

Reason seems to handle this while being compiled to AST and adds a trailing _, but it breaks syntax highlighting in the remainder of the file which is kind of annoying.

with ~method
image

without ~method
image

I propose just changing the label to httpMethod | verb | httpVerb

open to any other names of course ¯_(ツ)_/¯

Add cancelToken

Example code (facebook/react#8883 (comment)):

  fetchRepos() {
    // cancel the previous request
    if (this.source) {
      this.source.cancel('Operation canceled due to new request.')
    }

    // save the new request for cancellation
    this.source = axios.CancelToken.source();

    this.setState({networkState: 'loading' })

    let url = `https://api.github.com/users/${this.props.username}/repos`
    axios.get(url, { cancelToken: this.source.token })
      .then(response => this.setState({ repos: response.data, networkState: 'loaded' } ))
      .catch(error => {
        if (axios.isCancel(error)) {
          this.setState({ networkState: 'canceled' })
        } else {
          this.setState({ networkState: 'errored' })
        }
     });
  }

Removing/overriding default headers

Following the example for Headers in the readme:

let headers = Axios.Headers.fromDict(headersDict);
Axios.getc("https://example.com", Axios.makeConfig(~headers, ()));

I noticed that Axios appends default headers, like Accept: application/json, text/plain, */*. The service I am trying to connect with doesn't accept the Accept headers, and throws me a 406 -- Not Acceptable error.

Also, when I set the header dict like dict.set("accept", "*/*"), I noticed that the Accept header value gets appended with */* instead of being replace. The Accept header ultimately looks like:
Accept: application/json, text/plain, */*, */*.

I noticed that there is a way to remove the default header for the js library:
https://stackoverflow.com/questions/46656474/axios-remove-headers-authorization-in-1-call-only

Is there a way to remove default headers? Or override them?

The example (http GET) doesn't compile in ReasonML

`
25 │ didMount: (self) =>
26 │
27 │ Js.Promise.(
28 │ Axios.get("/user?ID=12345")
29 │ |> then
((response) => resolve(Js.log(response##data)))
30 │ |> catch((error) => resolve(Js.log(error)))
31 │ ),
32 │
33 │ /* Js.Promise.( */

This has type:
Js.Promise.t(unit) (defined as Js.Promise.t(unit))
But somewhere wanted:
unit
`

My bsconfig.json contains axios:

"bs-dependencies": [ "reason-react", "bs-jest", "bs-axios", "bs-css" ]

Sopport JSON body for POST?!

I use https://github.com/ryb73/ppx_decco to encode and decode the records and JSONs

To work with Axios I need to do

Axios.postData(url, mytype_encode(response) |> Obj.magic) |> then_(...)

did not try with GET but will be useful to have body and response as JSON?!
What do you think?!

Using a dictionary instead of Js.t for headers

Hi. Is there any way to use a dictionary instead of Js.t for headers? A scenario where I would either send "header1" or "header2" depending on a condition doesn't seem to be possible to compile, since the type of headers is defined by the first value, and thus the second one would be required to have the same shape.

Axios.makeConfigWithUrl(
  ~url="https://api.chucknorris.io/jokes/random",
  ~headers=
    checkCondition() ? {"header1": "value1"} : {"header2": "value2"},
  (),
);

The error I get is:

Error: This expression has type {. "header2": string}
       but an expression was expected of type {. "header1": string}

Is there any way to omit "header1" from the second value? Seems like a dictionary would be a structure that resembles HTTP headers more closely.

Axios dependency

hi @meafmira,

I think axios should be moved to peerDependencies. Especially since it is not used in generated files

redacted output of yarn why axios

yarn why v1.21.1
[1/4] 🤔  Why do we have the module "axios"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "[email protected]"
info Has been hoisted to "axios"
info Reasons this module exists
   - "workspace-aggregator-43088911-9698-4e6f-aaa9-6d34f43842d4" depends on it
info Disk size without dependencies: "488KB"
info Disk size with unique dependencies: "656KB"
info Disk size with transitive dependencies: "804KB"
info Number of shared dependencies: 3
=> Found "bs-axios#[email protected]"
info This module exists because "bs-axios" depends on it.
info Disk size without dependencies: "412KB"
info Disk size with unique dependencies: "604KB"
info Disk size with transitive dependencies: "752KB"
info Number of shared dependencies: 4
✨  Done in 0.95s.

Cleanup non issue

When my account was compromised a spam issue was created in this repo. I sincerely apologize. Cleaning up such issues via script.

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.