TYPE DEFINITION CONFUSION
Unanswered
Mr.Techbuddy 404 posted this in #help-forum
Here in my code I'm fetching the moc data and passing it though a type definition file where I have defined the type for data but as there is a key name as id for which I have defined the type as string but as on console it just printing the type number for id , how ?, it should print string as I have passed the data and have changed the data type !
import React from 'react'
import { Todo } from '../../typing';
const fetchTodo = async () =>{
const res = await fetch("https://jsonplaceholder.typicode.com/todos/");
const todos = await res.json();
console.log(typeof(todos[1].id))
}
const TodoList = async () => {
const todos = await fetchTodo();
return (
<div>
todolist
</div>
)
}
export default TodoList
import React from 'react'
import { Todo } from '../../typing';
const fetchTodo = async () =>{
const res = await fetch("https://jsonplaceholder.typicode.com/todos/");
const todos = await res.json();
console.log(typeof(todos[1].id))
}
const TodoList = async () => {
const todos = await fetchTodo();
return (
<div>
todolist
</div>
)
}
export default TodoList