Недавно я начал изучать React с Typescript. Я пытаюсь написать действия с asyn c и жду. но он показывает ошибку Unexpected token, expected "," (24:9)
index. js
import axios from "axios";
import { Dispatch } from "redux";
import { ActionTypes } from "./types"
export interface ToDo {
company_name: string,
created_at: Date,
description: string,
featured: boolean,
hashid: string,
location: string,
remote: boolean,
term: null,
title: string,
updated_at: string,
url: string
}
export interface FetchTodoActions{
type: ActionTypes.fetchTodos,
payload: ToDo[]
}
export const fetchTodos = ({
return async(dispatch:Dispatch)=> {
const response = await axios.get<ToDo[]>('https://codepen.io/jobs.json');
dispatch<FetchTodoActions>({
type: ActionTypes.fetchTodos,
payload: response.data
})
}
})
package. json:
{
"name": "react-ts",
"version": "1.0.0",
"description": "",
"keywords": [],
"main": "src/index.tsx",
"dependencies": {
"@babel/plugin-transform-runtime": "7.8.0",
"@babel/preset-env": "7.8.2",
"@babel/runtime": "7.8.0",
"@types/react-redux": "7.1.5",
"axios": "0.19.1",
"react": "16.8.4",
"react-dom": "16.8.4",
"react-redux": "7.1.3",
"react-scripts": "2.1.3",
"redux": "4.0.5",
"redux-thunk": "2.3.0"
},
"devDependencies": {
"@types/react": "16.8.8",
"@types/react-dom": "16.8.2",
"typescript": "3.3.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"babel": {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"browsers": [">0.25%", "not ie 11", "not op_mini all"]
}
}
],
"@babel/preset-react"
],
"plugins": ["@babel/plugin-transform-runtime"]
},
"browserslist": [">0.2%", "not dead", "not ie <= 11", "not op_mini all"]
}
Я делюсь ссылкой для кодов и ящиков, которые я реализовали:
https://codesandbox.io/s/ecstatic-river-bpc6y
Пожалуйста, помогите мне с этим.