Site icon Hip-Hop Website Design and Development

why is apiFetch throwing Unhandled Promise Rejection: TypeError: Object isn’t a perform

I am making an attempt to diagnose an analogous downside to this query, however in that case he wasn’t relying on wp-api-fetch, and … I am fairly certain I’m.

I am getting the next error:

[Error] Unhandled Promise Rejection: TypeError: Object isn't a perform. (In 'Object(_wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_5__["apiFetch"])', 'Object' is an occasion of Object)

(full backtrace, under)

I ought to be aware that I am new to each the REST API and ESNext/Gutenberg plugin development, so … I could also be lacking one thing actually apparent, like a comma 🙂

This is the code:

import { __ } from '@wordpress/i18n';
import { Fragment } from '@wordpress/factor';
import { TextControl } from '@wordpress/elements';
import { apiFetch } from '@wordpress/api-fetch';

export default perform Edit( props ) {
        const {
                attributes: { cwraggDataSourceType, cwraggDataSource,
                    cwraggLocalFile },
                setAttributes,
        } = props;

        const post_id = wp.knowledge.choose("core/editor").getCurrentPostId();

        const onChangeContent = async ( newUrl ) => {
                let localFileName = await apiFetch( {
                    path: '/cwraggb/v1/setremotedatasrc',
                    technique: 'POST',
                    knowledge: { 'url': newUrl,
                            'kind': 'json',
                            'postId': post_id } } );
                ...
  
        };
        ...
}

I regarded on the output of npm run begin, and it appears to be together with the dependencies within the construct:

<?php return array('dependencies' => array('wp-api-fetch', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'model' => '566e4b7cb2f100542103b2b0e25aefae');

That is being constructed, and docker run, on MacOS 10.15.7.

~ % npm --version
6.14.8
~ % wp-env --version
2.1.0

Any concepts what’s inflicting that error, and/or how I can additional diagnose?

Full error message:

[Error] Unhandled Promise Rejection: TypeError: Object isn't a perform. (In 'Object(_wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_5__["apiFetch"])', 'Object' is an occasion of Object)
    dispatchException (wp-polyfill.js:7017)
    invoke (wp-polyfill.js:6738)
    asyncGeneratorStep (cwra-google-graph-block-admin.js:250)
    _next (cwra-google-graph-block-admin.js:272)
    (nameless perform) (cwra-google-graph-block-admin.js:279)
    Promise
    (nameless perform) (cwra-google-graph-block-admin.js:268)
    callCallback (react-dom.js:341)
    dispatchEvent
    invokeGuardedCallbackDev (react-dom.js:391)
    invokeGuardedCallback (react-dom.js:448)
    invokeGuardedCallbackAndCatchFirstError (react-dom.js:462)
    executeDispatch (react-dom.js:594)
    executeDispatchesInOrder (react-dom.js:616)
    executeDispatchesAndRelease (react-dom.js:719)
    forEach
    forEachAccumulated (react-dom.js:699)
    runEventsInBatch (react-dom.js:744)
    runExtractedPluginEventsInBatch (react-dom.js:875)
    handleTopLevel (react-dom.js:6026)
    dispatchEventForPluginEventSystem (react-dom.js:6121)
    dispatchEvent (react-dom.js:6150)
    dispatchEvent
    unstable_runWithPriority (react.js:2820)
    discreteUpdates$1 (react-dom.js:21810)
    discreteUpdates (react-dom.js:2357)
    dispatchDiscreteEvent (react-dom.js:6104)
    dispatchDiscreteEvent