Robot Not a Dev? Pre-order Now
Not a Dev?

Documentation Improvements

docs

#1

In the tutorials, axios.post("http://" + ip + "/api/led/change", data) is followed by the same command.

There are three different commands that are slowly building up what to do, and I am not sure if it is necessary to have this part of the code as three commands building up the axios.post, then repeating it and adding the then, and then repeating both parts and adding the catch.

Using the final command and adding all of the comments may be a better option.


#2

Thanks for sending this and welcome to the Misty community!


#3

Thanks, Ben.

I am new to JavaScript, and I was not sure how to properly format this section of code.

    .then(function (response) { 
        console.log(`ChangeLED was a ${response.data[0].status}`)
    // Use a catch() method after then(). catch() triggers if the promise is rejected. Pass a callback to catch() to print any errors returned by the request to the console.
    .catch(function (error) {
        console.log(`There was an error with the request ${error}`);
    })
})

This is the error that I saw: MistyTutorial.html:23 Uncaught (in promise) TypeError: Cannot read property 'catch' of undefined

It seems like the backticks in the console.log created JavaScript errors. I still have other errors though.


#4

Hey, I figured out the issue, the code should be

axios.post("http://" + ip + "/api/led/change", data)
.then(function (response) {
    console.log('ChangeLED was a ${response.data[0].status}');})
 .catch(function (error) {
            console.log('There was an error with the request ${error}');
        })

#5

Ah, thank so much for catching this! We’ll update the docs to fix the syntax (& to break up those comment lines so they’re easier to read! :slight_smile: )