Uncaught SyntaxError: Unexpected reserved word in a {name} file

bohokep350

I'm in a weird situation where I get this error: Uncaught SyntaxError: Unexpected reserved word (at addLocalSkillset.js?t=1654154827218:28:21), I tried to remove the headers variable, and URL variable, but still that error is found.

In fact, if you see the file, No reserved word is being used, isn't that weird?

import { API_URL, API_KEY } from '../../../@constants/Global/Env';

const addLocalSkillset = (workSpaceId) => {

    const newSkillset = {
        skills_group: `Untitled ${Math.random().toString().substring(2, 5)}`,
        skills_set: [],
        workSpaceId: workSpaceId,
    };

    const _URL = `${API_URL}/predefinedskills`;

    const _headers = {
        'api-key': API_KEY,
        'user-token': token,
    };

    var body = new FormData();
    body.append('predefinedSkills', JSON.stringify(newSkillset));

    const requestOptions = {
        method: 'POST',
        headers: _headers,
        body: body,
    };

  try {
    const request = await fetch(_URL, requestOptions);
    const response = await request.json();
    console.log('result', response);

    if (response.status === true) {
      return {
        data: res.data,
        status: true,
        message: 'Succesfully added a skill set.',
      };
    } else {
      return {
        status: false,
        message: "Something wen't wrong adding a skill set.",
      };
    }
  } catch (error) {
    return {
      status: false,
      message: "Something wen't wrong adding a skill set.",
    };
  }
}

export default addLocalSkillset;
Ivana Murray

Add async when declaring the function just before the variables

const addLocalSkillset = async (workSpaceId) => {

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related