Comments (13)
@breadadams you should be good to go! here's a codesandbox showing it in action: https://codesandbox.io/s/fetch-api-in-express-kwfq8
The fetch api processes gifs after fetching, it normalizes some weirdness in our api responses and also helps us track which endpoint the gifs came from for our metrics.
If you have any issues lmk!
from giphy-js.
@devpascoe react-native
support is on the wish list! but not exactly on our roadmap just yet, feel free to create an issue and we can hopefully get started on it
from giphy-js.
@budde377 I left it up to you to add the polyfill for fetch. In my experience, this is customary for libraries with polyfills. In the codesandbox I listed above, I used isomorphic-fetch
.
I think this approach is best, because I wouldn't want to include a polyfill in the package that globally shims anything, it might override something in your application.
It also keeps the bundle size down
from giphy-js.
@breadadams it wasn't a product requirement, but if headers
is the only issue with node support then we can find a way to do it. In your environment, you can maybe require isomorphic-fetch before you require our lib. If there are other issues, lmk and I'll see what we can do about headers
from giphy-js.
@breadadams released the new packages below that don't have the headers in fetch api, lmk if there are any other blockers for node!
- @giphy/js-components: 2.4.3
- @giphy/js-fetch-api: 1.5.3
- @giphy/react-components: 0.7.3
from giphy-js.
@breadadams I realized the headers are still referenced in our util package, will follow up when I have time to fix this
from giphy-js.
Ahh of course - no worries @giannif. Thanks for the effort here!
I ended up using the API directly in the end, which works for us as it's only a single request to the search API (you can see it here). However I'll be happy to move it over the the SDK once it's available 🙌
from giphy-js.
Something to look into is React Native support. Unable to get an iOS app running, comment out import { GiphyFetch } from '@giphy/js-fetch-api' and i am working again. Can use urls directly for now.
from giphy-js.
Thanks @giannif - I'll give it a shot this week!
@devpascoe react-native support would be nice! I'd open a separate issue for it and post the error logs you're getting. I'm sure they'll be able to sort it 😉💪
from giphy-js.
@giannif, I might be missing something, but it looks like you're still not supporting node, because you assume that fetch
is available? I'm getting the error
Error: fetch is not defined
at new FetchError (.../node_modules/@giphy/js-fetch-api/src/fetch-error.ts:5:9)
at Object.<anonymous> (.../node_modules/@giphy/js-fetch-api/src/request.ts:37:30)
...
because of a call to fetch here https://github.com/Giphy/giphy-js/blob/master/packages/fetch-api/src/request.ts#L19 .
It might be worth using https://www.npmjs.com/package/isomorphic-fetch or allowing users to pass their own fetch in the GiphyFetch
constructor?
Edit: A quick fix for this is assigning fetch
globally
global.fetch = require('node-fetch')
from giphy-js.
Yeah, the polyfill should be handled at project level - not in the Giphy SDK 👍
from giphy-js.
@giannif That makes sense, thanks!
from giphy-js.
Works for me in Typescript with API's in Node
import fetch from "node-fetch";
declare var global: any;
global.fetch = fetch;
from giphy-js.
Related Issues (20)
- How to pick the format having only the id? HOT 3
- Gif does not support keypress event HOT 3
- At Grid component: "Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method." HOT 1
- Add support for AbortController HOT 1
- Consider making pingback and remote fonts configurable HOT 4
- Why there is no 'clips' type? HOT 1
- Carousel does not pass noLink property HOT 1
- Giphy React Grid component is not working HOT 4
- Please upgrade to react18 HOT 5
- SearchBar component make search button optional HOT 2
- Giphy/react-components 5.13.0 corporate proxy issue HOT 1
- renderGrid gifs positions are not set properly in lit HOT 2
- Focused Gif is not visually emphasized HOT 4
- Remove Grid not working HOT 1
- `require` in ESM build HOT 2
- `SyntaxError: Named export 'appendGiphySDKRequestHeader' not found. The requested module '@giphy/js-util' is a CommonJS module, which may not support all module.exports as named exports.` HOT 2
- It is advised to avoid ship styled-components in the build bundle. HOT 5
- React logging errors similar to "React does not recognize the `isFirstLoad` prop on a DOM element." HOT 1
- Next.js build fails: "Module not found: Can't resolve 'styled-components'" HOT 2
- Security concern: qs vulnerable to Prototype Pollution
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from giphy-js.