fetch response.json() gives responseData = undefined

前端 未结 6 854
青春惊慌失措
青春惊慌失措 2020-12-01 06:34

When using fetch:

  fetch(REQUEST_URL, {
      method: \'get\',
      dataType: \'json\',
      headers: {
        \'Accept\': \'application/json\',
             


        
6条回答
  •  渐次进展
    2020-12-01 06:51

    import React, {useEffect} from 'react';
    
    useEffect(() => {
        getRecipes();
      }, []);
    
      const getRecipes = async () => {
        const response = await fetch(
          `https://........`
        );
        const data = await response.json();
        console.log(data);

    • Use this method You can easily fatch data.

提交回复
热议问题