Home > Back-end >  How to destructure object in React with special characters in key
How to destructure object in React with special characters in key

Time:08-29

Backend returns an object, and one of the key-value, I would handle differently, how can I split up object?

useEffect(() => {
    const tempUserShortId = getTempUserShortId()
    axios({
        method: 'get',
        url: `questionList?tempUserId=${tempUserShortId}&questionIds[]=6f50dbea-196b-4fb6-82ee-fbade62aab98&questionIds[]=6f50dbea-196b-4fb6-82ee-fbade62aab99&questionIds[]=6f50dbea-196b-4fb6-82ee-fbade62aab9a`,
        headers: { crossDomain: true },
    }).then((res) => {

        const {'6f50dbea-196b-4fb6-82ee-fbade62aab9a', ...rest} = res.data;
        setQuestions(rest)
    })
}, [ind])

It says: ':' expected.ts(1005

Found this online:

  const removeKey = () => {
    setEmployee(current => {
      //            
  • Related