I would like to use the library aws-amplify
in nodejs.
Because this library uses fetch APIs, JavaScript/nodejs was solved by using node-fetch
as follows:
constamplify=require('aws-amplify');
global.fetch=require("node-fetch");
However, I don't know how to configure the same settings in TypeScript.
I understood that there was a way to specify the global variable (type?) such as the declare
keyword, but I didn't know how to replace it with the implementation of node-fetch
.
How can I use fetch, or could you give me some advice and help me with reference materials?
aws node.js typescript
It could be replaced like this.
import fetch, {Request, RequestInit, Response} from 'node-fetch';
interface Global { fetch (url:string | Request, init?: RequestInit | undefined): Promise <Response >}
declare var global —Global
global.fetch=fetch
© 2024 OneMinuteCode. All rights reserved.