funcool / promesa

A promise library & concurrency toolkit for Clojure and ClojureScript.
https://funcool.github.io/promesa/latest/
Mozilla Public License 2.0
498 stars 58 forks source link

doesn't catch axios fail #122

Closed agriffis closed 2 years ago

agriffis commented 2 years ago

In node, we can catch an axios failure

const axios = require('axios')

axios.get('https://aeoifjasodifjaosiejfaoisedjfaoisdjf.com')
     .then(() => console.log('woo'))
     .catch(() => console.log('boo'))  //=> prints "boo" on console

In promesa, this doesn't seem to work

(ns foo
  (:require [promesa.core :as p]
            ["axios$default" :as axios]))

(p/-> (axios/get "https://aeoifjasodifjaosiejfaoisedjfaoisdjf.com")
      (p/then #(js/console.log "woo"))
      (p/catch #(js/console.log "boo")))  ;=> nothing is printed

I've tried a bunch of things, but it seems like neither then nor catch is called when axios fails in promesa.

agriffis commented 2 years ago

Bah, I was using p/-> when I need simple -> in this case.