You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That's providers/Http/index.js file. Here the config/http.js is a file with a copy of axios library configurations. The most important is baseURL: 'http://api.chucknorris.io'.
const { test } = use('Test/Suite')('Http Provider')
const HttpProvider = use('HttpProvider')
test('Should make a get', async ({ assert }) => {
const response = await HttpProvider.get('/jokes/random')
assert.equal(response.status, 200)
})
Finally when I run the test, the response variable looks undefined.
Http Provider
✖ Should make a get (7ms)
ERRORS
1. Should make a get
expected undefined to equal 200
undefined => 200
FAILED
total : 1
failed : 1
time : 22ms
I cannot understand why this behaviour. Is it possible to make the library work in this way?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone,
I'm using adonis 4.1 legacy version. I followed this guide https://legacy.adonisjs.com/docs/4.1/service-providers#_npm_package_as_a_service_provider because I want use axios in my application and I want to have only a single instance of it.
That's
providers/Http/index.js
file. Here theconfig/http.js
is a file with a copy of axios library configurations. The most important isbaseURL: 'http://api.chucknorris.io'
.and that's my
providers/Http/Provider.js
file.I then wrote a stupid test:
Finally when I run the test, the response variable looks undefined.
I cannot understand why this behaviour. Is it possible to make the library work in this way?
Thank you
Beta Was this translation helpful? Give feedback.
All reactions