ReferenceError: self is not defined
See original GitHub issueI’ve incorporated isomorphic-fetch
into a library I made called react-reach
and it works great in the browser however when I try it out in node I get the following error in my console:
module.exports = self.fetch.bind(self);
^
ReferenceError: self is not defined
I’m not exactly sure why this is going on however heres the library code that uses isomorphic-fetch
:
import fetch from 'isomorphic-fetch';
export function transport (path, query, queryParams, token) {
return fetch(path, {
method: 'POST',
headers: {
'Accept': 'application/json',
'content-type': 'application/json',
'authorization': token
},
body: JSON.stringify({
query,
queryParams
})
})
.then((response) => {
return response.json();
})
.then((responseBody) => {
if (responseBody && responseBody.errors) {
throw new Error(responseBody.errors);
}
return responseBody.data;
});
}
Here is the userland code used in node:
import { reachGraphQL } from 'react-reach';
var imgUri = `http://localhost:8080/users/${req.params.id}/${req.file.originalname}`;
reachGraphQL(`http://localhost:8080/`, `mutation {
profilePic: updateUser(profilePicture: "${imgUri}"){
profilePicture
}
}`)
If you know why this may be occurring please let me know as I depend on this library for an application at my job.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6
Top Results From Across the Web
Typescript + Webpack library generates "ReferenceError
This issue is related to the option output.globalObject of which is described here. I believe webpack has set it as self for a...
Read more >ReferenceError: self is not defined · Issue #2172
bug report When building with parceljs where node-fetch is required, the below error is thrown when running the compiled js Configuration ...
Read more >ReferenceError: self is not defined - Technical
This means that there is a non-existent variable referenced somewhere. This variable needs to be declared, or you need to make sure it...
Read more >node-self
Start using node-self in your project by running `npm i ... But, in Node.js console.log(self); // ReferenceError: self is not defined.
Read more >NextJS ReferenceError: self is not defined
Hi everyone,. I keep getting error every time I refresh the page that renders the map. I'm using the “@tomtom-international/web-sdk-maps” and “@ ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Wait, this isn’t a solution. Now it’s not available in your build.
Is this a regression with webpack v2? I have been previously been able to bundle isomorphic-fetch with webpack, now that I’ve upgrade to v2 beta I am seeing the
self
error.