Skip to content

v2.0.0

Compare
Choose a tag to compare
@delvedor delvedor released this 07 Jan 12:16
  • Added error handling - #10 #11

v1

// callback
inject(dispatch, { method: 'get', url: '/' }, (res) => {
  console.log(res.payload)
})

// promises
inject(dispatch, { method: 'get', url: '/' })
  .then(res => console.log(res.payload))

// async-await
const res = await inject(dispatch, { method: 'get', url: '/' })
console.log(res.payload)

v2

// callback
inject(dispatch, { method: 'get', url: '/' }, (err, res) => {
  console.log(res.payload)
})

// promises
inject(dispatch, { method: 'get', url: '/' })
  .then(res => console.log(res.payload))
  .catch(console.log)

// async-await
try {
  const res = await inject(dispatch, { method: 'get', url: '/' })
  console.log(res.payload)
} catch (err) {
  console.log(err)
}