(solved) parsing error

Im not good with {} i guess, but adding {} to my code as the code editor told me to but im still having problems can someone plz help?(i have the error at the last part } of the code)

function App() {

      const [inputField, setInputField]= useState('')

      const [userInput, setUserInput] = useState('')

      const [savedInput, setSavedInput] = useState('')

      const [edits, setEdits] = useState([])

      const [charsLeft, setCharsLeft]= useState(50000)

      const [newEditState, setNewEditState]= useState('')

      const [wrongWord, setWrongWord] = useState('')

      useEffect(()=>{

        checkMyGrammar()

      },[])

  //axios call

  checkMyGrammar = () => {

    axios ({

      method: 'GET',

      url: 'https://proxy.hackeryou.com',

      dataResponse: 'JSON',

      paramsSerializer: function(params) {

        return Qs.stringify(params, {arrayFormat: 'brackets'})

      },

      params: {

        reqUrl: 'http://api.grammarbot.io/v2/check',

        params: {

            queryParam: userInput,

            key: '#',

            format: 'JSON',

            text: userInput,

            language: 'en-US',

        }, 

        proxyHeaders: {

          'header_params': 'value',

        },

        xmlToJSON: false,

      } 

    })

    .then((results) => {

        setEdits(results.data.matches)

        setWrongWord(results.data.matches.map((misspelling) => {  

          return userInput.slice(misspelling.context.offset, misspelling.context.offset + misspelling.context.length)

        })

      })

If you just paste the code in codepen.io you’ll find every single error…

2 Likes

yea just tried it and followed wat is said and it still gives me an error

Then maybe try to remove the useless parts of code, so either you or someone else do not need to read the full code. Debugging takes time :sweat_smile:

you r right man i was just being too lazy haha

1 Like

Hello!

See the comments:

function App() {

      const [inputField, setInputField]= useState('')

      const [userInput, setUserInput] = useState('')

      const [savedInput, setSavedInput] = useState('')

      const [edits, setEdits] = useState([])

      const [charsLeft, setCharsLeft]= useState(50000)

      const [newEditState, setNewEditState]= useState('')

      const [wrongWord, setWrongWord] = useState('')

      useEffect(()=>{

        checkMyGrammar()

      },[])

  //axios call

  checkMyGrammar = () => {

    axios ({

      method: 'GET',

      url: 'https://proxy.hackeryou.com',

      dataResponse: 'JSON',

      paramsSerializer: function(params) {

        return Qs.stringify(params, {arrayFormat: 'brackets'})

      },

      params: {

        reqUrl: 'http://api.grammarbot.io/v2/check',

        params: {

            queryParam: userInput,

            key: '#',

            format: 'JSON',

            text: userInput,

            language: 'en-US',

        }, 

        proxyHeaders: {

          'header_params': 'value',

        },

        xmlToJSON: false,

      } 

    })

    .then((results) => {

        setEdits(results.data.matches)

        setWrongWord(results.data.matches.map((misspelling) => {  

          return userInput.slice(misspelling.context.offset, misspelling.context.offset + misspelling.context.length)

        }) // <-- You're missing a )

      })
// You're missing a }
// You're missing a }
2 Likes

thanks so much for helping me!

1 Like

If you use VS Code, the Bracket Pair Colorizer extension is pretty handy.

3 Likes