Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using method options #61

Closed
aalfiann opened this issue Jan 19, 2021 · 4 comments
Closed

Error when using method options #61

aalfiann opened this issue Jan 19, 2021 · 4 comments
Labels

Comments

@aalfiann
Copy link

I've tried like this

var request = ajax({
  method: 'options',
  url: '/api/users',
  data: JSON.stringify({
    user: 'john'
  })
});

request.then(function (response) {...});

but I got error request.then is not a function?
what's wrong?

@fdaciuk
Copy link
Owner

fdaciuk commented Sep 4, 2021

Hi @aalfiann! I've tried the exact same code, and everything works just fine =)
Did you install the library on your project?

@fdaciuk fdaciuk closed this as completed Sep 4, 2021
@aalfiann
Copy link
Author

Sorry late for reply..

I use this library by using cdn, so should I install this to make this work?

@fdaciuk
Copy link
Owner

fdaciuk commented Sep 28, 2021

When using from CDN, you don't have to install anything else.
I tried here, and it works well either.

Check if you have ajax function is available globally (check the result of console.log(ajax)).
If it is not, try to use window.ajax() or globalThis.ajax() instead of just ajax() ;)

@aalfiann
Copy link
Author

awesome, I use window.ajax() and its working now.. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants