-
Notifications
You must be signed in to change notification settings - Fork 64
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
Testing front end code. #529
Comments
If your success/failure methods aren't working, it's likely that you're not getting to the point where you're making an ajax call. I like to be very methodical about my front end code:
|
So, I think that I've successfully completed step 5. Here is the what my back end server is saying when I try to get all books. Started GET "/books" for ::1 at 2016-12-02 09:41:33 -0500 But, I'm not having any success with step 6. |
Can you post the code? The success function, and where you use it. Before you do that, double check that you're using the success function that you think you're using. 😉 |
//events.js
const onGetBooks = function() {
console.log('bad mood');
api.getIndex()
.then(ui.success)
.catch(ui.failure);
};
//api.js
const getIndex = () =>
$.ajax ({
url: config.host + '/books',
method: 'GET',
headers: {
Authorization: 'Token token=' + store.user.token
}
});
//ui.js
const success = () => {
console.log('YAY!!!!');
}; |
Are you getting any errors on the front end? |
Nope, just this in the console: jquery.js:9536 XHR finished loading: GET "http://localhost:4741/books".send @ jquery.js:9536ajax @ jquery.js:9143getIndex @ api.js:17onGetBooks @ events.js:19dispatch @ jquery.js:5201elemData.handle @ jquery.js:5009 |
I wasn't actually exporting the functions because I had: module.*export* = {
success,
failure,
addBookSuccess,
addBookFailure,
};
//INSTEAD OF
module.*exports* = {
success,
failure,
addBookSuccess,
addBookFailure,
}; |
I'm having trouble getting my front end code to work the way that I expect. I understand the theoretical structure of the events and ui functions and the api ajax calls, but I'm still having issues. Is there a good way to test my front end code, something like a curl request, but for the front end? I've tried to get a console log message from my success/ failure methods without success, which makes me think that the problem might be what I'm including or missing in my ajax calls.
The text was updated successfully, but these errors were encountered: